from datetime import timedelta from datetime import date from datetime import time from time import localtime import datetime ##Date Objects # get todays date from the simple today () method from the date class today = (2013,10,12) print "Today's date is " , today # print out date's individual components datetime.month = (10) datetime.date = (15) datetime.year = (2013) now = datetime.datetime.now() print datetime.month, datetime.date, datetime.year print now # retrive today's weekday (0=Monday, 6=Sunday) make list of specific dates Monday = (14) Monday_2 = (21) Monday_3 = (28) Tuesday = (1) Wednesday = (2) Thursday = (3) Friday = (4) Saturday = (5) Sunday = (6) day = "Monday" day_1 = "Tuesday" day_2 = "Wednesday" day_3 = "Thursday" day_4 = "Friday" day_5 = "Saturday" day_6 = "Sunday" print "These are the monday meeting dates in October over the next 3 weeks", Monday,Monday_2,Monday_3 print Tuesday,Sunday,Thursday print "today is ", day,"the", Monday def main(): t = datetime.time() print "The current time is", t
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question