Python 字符串转换成时间

 

r[0] = '20181026'
dtr = datetime.datetime.strptime(r[0], "%Y%m%d")
finalR = dtr.strftime("%Y-%m-%d")

 

'2018-10-26'

 

 

参考:

https://www.cnblogs.com/alfred0311/p/7885349.html

posted @ 2021-03-16 10:23  bH1pJ  阅读(29)  评论(0编辑  收藏  举报