[Tutor] how to use the time module?

Jacob S. keridee at jayco.net
Sun Nov 7 03:13:29 CET 2004

>import string
>import datetime

>y,m,d=string.split(raw_input("Enter a date('YYYY-MM-DD'):"),"-")
>print a.strftime('%A')

I can make it simpler yet
First, get rid of importing the string module. You only want string.split()
and you can use string methods for that.
Then, you can change the code from there to:

import datetime

y,m,d = raw_input("Enter a date('YYYY-MM-DD'):").split("-")
a = datetime.date(int(y),int(m),int(d))
print a.strftime("%A")

Jacob Schmidt

More information about the Tutor mailing list