如何把 01/01/2012 01:00:00 转换成 utc?
How to convert 01/01/2012 01:00:00 to utc?
我已尝试转换我的时间数据,以便我的 python 脚本可以读取此数据。我试过了
Time.append(row[1])
Time = Time[1:]
Time = [str (i) for i in Time]
datetime_Time = datetime.datetime ("%Y%m%d %I:%M:%S") #pharsing the time
print (Time)
我尝试将数据作为浮点数和整数传递 too.But,因为我的数据使用“/”和 :,因此这会导致错误,如果有人能告诉我如何阅读,我将不胜感激这个数据
这应该有所帮助。
import datetime
s = "01/01/2012 01:00:00"
print( datetime.datetime.strptime(s, "%m/%d/%Y %H:%M:%S").strftime("%Y%m%d %I:%M:%S") )
输出:
20120101 01:00:00
我已尝试转换我的时间数据,以便我的 python 脚本可以读取此数据。我试过了
Time.append(row[1])
Time = Time[1:]
Time = [str (i) for i in Time]
datetime_Time = datetime.datetime ("%Y%m%d %I:%M:%S") #pharsing the time
print (Time)
我尝试将数据作为浮点数和整数传递 too.But,因为我的数据使用“/”和 :,因此这会导致错误,如果有人能告诉我如何阅读,我将不胜感激这个数据
这应该有所帮助。
import datetime
s = "01/01/2012 01:00:00"
print( datetime.datetime.strptime(s, "%m/%d/%Y %H:%M:%S").strftime("%Y%m%d %I:%M:%S") )
输出:
20120101 01:00:00