Python程序教程

您现在的位置是:首页 >  python爬虫

当前栏目

Python获取时间戳_python爬虫时间戳

时间,Python,获取,python,爬虫
2025-03-13 21:27:29 时间

大家好,又见面了,我是你们的朋友全栈君。

获取时间戳

import time
def get_time_stamp() -> str:
    _t = time.localtime()
    time_stamp = f"{str(_t.tm_mon).zfill(2)}{str(_t.tm_mday).zfill(2)}" + \
        f"-{str(_t.tm_hour).zfill(2)}{str(_t.tm_min).zfill(2)}{str(_t.tm_sec).zfill(2)}"
    return time_stamp


TIME_STAMP = get_time_stamp()
print('月日-时分秒{TIME_STAMP}'.format(TIME_STAMP=TIME_STAMP))
TIME_STAMP = str(datetime.datetime.now()).replace(" ","_").replace(":","-")

TypeError: ‘int’ object is not iterable

for i in len(a):
改为
for i in range(len(a)):

发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/189145.html原文链接:https://javaforall.cn