python获取当天日期,python获取当天,import datet


import datetime# Get a date objecttoday = datetime.date.today()# General functionsprint "Year: %d" % today.yearprint "Month: %d" % today.monthprint "Day: %d" % today.dayprint "Weekday: %d" % today.weekday() # Day of week Monday = 0, Sunday = 6# ISO Functionsprint "ISO Weekday: %d" % today.isoweekday() # Day of week Monday = 1, Sunday = 7print "ISO Format: %s" % today.isoformat() # YYYY-MM-DD formatprint "ISO Calendar: %s" % str(today.isocalendar()) # Tuple of (ISO year, ISO week number, ISO weekday)# Formatted dateprint today.strftime("%Y/%m/%d") #

评论关闭