首页 > 代码库 > python获取当天日期
python获取当天日期
http://www.sharejs.com/codes/python/8032
import datetime # Get a date objecttoday = datetime.date.today() # General functions print "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") ##该代码片段来自于: http://www.sharejs.com/codes/python/8032
python获取当天日期
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。