使用 python 从字符串/日期时间获取日期格式代码

时间:2021-01-18 14:05:48

标签: python datetime formatting timestamp data-cleaning

有没有办法在 Python 中找出字符串的日期格式代码?

我的输入将是例如:

<块引用>

2020-09-11T17:42:33.040Z

我正在寻找的是在这个例子中得到这个:

<块引用>

'%Y-%m-%dT%H:%M:%S.%fZ'

重点是我有不同文件的不同时间格式,因此我不知道在 Advancce 中我的日期时间代码格式会是什么样子。

为了处理我的数据,我需要 unix 时间格式,但为了计算我需要解决这个问题。

data["time_unix"] = data.time.apply(lambda row: (datetime.datetime.strptime(row, '%Y-%m-%dT%H:%M:%S.%fZ').timestamp()*100))

感谢您的支持!

0 个答案:

没有答案
相关问题