A-A+
python3 时间戳转换格式化时间报错 AttributeError strftime

【注意:此文章为博主原创文章!转载需注意,请带原文链接,至少也要是txt格式!】
报错误一:python3 {TypeError}Tuple or struct_time argument required
报错二:{AttributeError}'int' object has no attribute 'strftime'
其实主要的原因就是转换的问题。所以需要注意他们之间的转换关系
时间戳——时间元祖&时间元祖——格式化时间 是能相互转换的
但是,时间戳——格式化时间 不能直接相互转换,需要转为时间元祖进行过渡。 正确的转换方法代码如下:
def Time_Y_M_D(self, times):
return time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(times))
times 为Linux 时间戳。
布施恩德可便相知重
微信扫一扫打赏
支付宝扫一扫打赏