添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
time2 = '26September2018' time_format2=datetime.datetime.strptime(time2,'%d%B%Y') print (time_format2)

其他方法:

使用正则的话

数值型转日期型 python python将数字转化为日期_正则_03


数值型转日期型 python python将数字转化为日期_正则_04

import re
time2 = '26September2018'
month = re.search('(\d+)(\w+?)(\d+)',time2).group(2)
year = re.search('(\d+)(\w+?)(\d+)',time2).group(3)
day = re.search('(\d+)(\w+?)(\d+)',time2).group(1)
print(month)
print(year)
print(day)