爬下来一串浮点,为什么没有办法转换成正常时间

1.67604066e+18
用localtime,strftime等都报错,应该怎么转换成正常的时间

1.67604066e+18 肯定不对了,18太大了,你把18换成9,就可以得到一个时间了

img

该回答引用ChatGPT

1.67604066e+18是一个数字,不是时间,不能直接使用localtime和strftime转换成时间。如果要转换为时间,需要先确定这个数字代表什么时间,比如是unix时间戳,那么可以使用time模块来转换:


import time

timestamp = int(1.67604066e+18)
time_struct = time.localtime(timestamp)
normal_time = time.strftime("%Y-%m-%d %H:%M:%S", time_struct)
print(normal_time)

但是,由于数字的精度超出了unix时间戳的范围(unix时间戳的最大值为2147483647),所以转换结果不正确。

如果要将这个数字转换为正常的时间,请首先确定这个数字是什么数据,并询问数据来源,以确定转换方法。