[Python] python获取当天日期 →→→→→进入此内容的聊天室

来自 , 2019-07-25, 写在 Python, 查看 112 次.
URL http://www.code666.cn/view/13d4635d
  1. import datetime
  2.  
  3. # Get a date object
  4. today = datetime.date.today()
  5.  
  6. # General functions
  7. print "Year: %d" % today.year
  8. print "Month: %d" % today.month
  9. print "Day: %d" % today.day
  10. print "Weekday: %d" % today.weekday() # Day of week Monday = 0, Sunday = 6
  11.  
  12. # ISO Functions
  13. print "ISO Weekday: %d" % today.isoweekday() # Day of week Monday = 1, Sunday = 7
  14. print "ISO Format: %s" % today.isoformat() # YYYY-MM-DD format
  15. print "ISO Calendar: %s" % str(today.isocalendar()) # Tuple of (ISO year, ISO week number, ISO weekday)
  16.  
  17. # Formatted date
  18. print today.strftime("%Y/%m/%d") #
  19. #//python/8032

回复 "python获取当天日期"

这儿你可以回复上面这条便签

captcha