Python_报错:TypeError: Tuple or struct_time argument required

Posted 翻滚的小强

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Python_报错:TypeError: Tuple or struct_time argument required相关的知识,希望对你有一定的参考价值。

报错:TypeError: Tuple or struct_time argument required

原因:时间戳和格式化处理时间不能直接使用会报错

 

上代码:

import time

time3 = time.asctime(time.time())#

print ("本地时间为 :",time3)

>>> import time
>>> time3 = time.asctime(time.time())#
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: Tuple or struct_time argument required
>>> print ("本地时间为 :",time3)

 

所以需要注意他们之间的转换关系

时间戳——时间元祖&时间元祖——格式化时间 是能相互转换的

但是,时间戳——格式化时间 不能直接相互转换,需要转为时间元祖进行过渡

以上是关于Python_报错:TypeError: Tuple or struct_time argument required的主要内容,如果未能解决你的问题,请参考以下文章