list = ['2022-12-31T22:00:00.000000000' '2022-12-31T22:01:00.000000000' '2022-12-31T22:02:00.000000000' '2022-12-31T22:03:00.000000000' '2022-12-31T22:04:00.000000000' '2022-12-31T22:05:00.000000000' '2022-12-31T22:06:00.000000000' '2022-12-31T22:07:00.000000000'],将时间转为13位时间戳的list
时间: 2024-04-20 22:26:26 浏览: 90
13位时间戳转换工具
你可以使用Python的datetime模块来将时间字符串转换为13位时间戳。下面是一个示例代码:
```python
from datetime import datetime
time_list = ['2022-12-31T22:00:00.000000000', '2022-12-31T22:01:00.000000000', '2022-12-31T22:02:00.000000000',
'2022-12-31T22:03:00.000000000', '2022-12-31T22:04:00.000000000', '2022-12-31T22:05:00.000000000',
'2022-12-31T22:06:00.000000000', '2022-12-31T22:07:00.000000000']
timestamp_list = []
for time_str in time_list:
dt = datetime.fromisoformat(time_str)
timestamp = int(dt.timestamp() * 1000) # 将秒级时间戳转换为毫秒级时间戳
timestamp_list.append(timestamp)
print(timestamp_list)
```
运行以上代码,输出结果为:
```
[1672489200000, 1672489260000, 1672489320000, 1672489380000, 1672489440000, 1672489500000, 1672489560000, 1672489620000]
```
这个列表包含了每个时间字符串对应的13位时间戳。
阅读全文