这是我的代码:
# Given an Unix timestamp in milliseconds (ts), return a human-readable date and time (hrdt)
def parseTS(ts):
hrdt = time.strftime("%a, %d %b %Y %H:%M:%S +0000", time.time(int(ts)/1000))
return str(hrdt)
我收到这个错误:
TypeError: time() takes no arguments (1 given)
更新:
这有效:
hrdt = datetime.datetime.fromtimestamp(int(ts)//1000)
return hrdt
最佳答案
time.time(int(ts)/1000) 函数错误。
尝试使用 time.ctime、time.gtime() 或 time.localtime() 函数之一来实现您想要的效果。
关于python - 我无法在 python 中使用 time() 找出这个错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7655531/