有关于时间转换
split函数
s1 = ' lcy is a pig'
for i in s1.split(): # ['lcy','is','a','pig']
print (i)
s2 = ' lcy is a pig'
for i in s2.split(' '): # ['','lcy','is','a','pig']
print (i)
s3 = ' lcy is a pig'
for i in s3.split('is'): #[' lcy',' a pig']
print(i)
2023-11-11 00:00:00 的各种变形
2023/11/11 00:00:00
s = '2023/11/11 00:00:00'
time_item = s.split() #['2023/11/11','00:00:00']
time = time_item[1]
date = time_item[0]
yy = date.split('/')[0]
mm = date.split('/')[1]
dd = date.split('/')[2]
pub_time = yy + '-' + mm + '-' + dd +' ' + time
print(pub_time)
知识点: 字符串split函数,字符串的拼接
Nov 11, 2023
from common import date
s = 'Nov 11, 2023'
time_item = s.split(' ') #['Nov','11,','2023']
mm = date.EN_1866_DATE[time_item[0]]
dd = time_item[1].split(',')[0]
yy = time_item[2]
pub_time = str(yy) + '-' + str(mm) + '-' + str(dd) +' ' + '00:00:00'
print(pub_time)
知识点: 字符串split函数,字符串的拼接,运用框架的字典
标签:11,00,转换,2023,item,时间,split,time,关于 From: https://www.cnblogs.com/howardsblog/p/17826127.html