[Python] python字符串和日期的相互转换 →→→→→进入此内容的聊天室

来自 , 2020-02-03, 写在 Python, 查看 132 次.
URL http://www.code666.cn/view/d3696cfb
  1. '''
  2. Created on 2009-9-2
  3. @author: jiangqh
  4. '''
  5. import time,datetime
  6. # date to str
  7. print time.strftime("%Y-%m-%d %X", time.localtime())
  8. #str to date
  9. t = time.strptime("2009 - 08 - 08", "%Y - %m - %d")
  10. y,m,d = t[0:3]
  11. print datetime.datetime(y,m,d)
  12.  
  13.  
  14. #//python/7148

回复 "python字符串和日期的相互转换"

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

captcha