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)

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

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

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

原文地址:https://www.cnblogs.com/rychh/p/9742413.html

时间: 2024-08-29 23:35:28

Python_报错:TypeError: Tuple or struct_time argument required的相关文章

Python_报错:TypeError: file must have &#39;read&#39; and &#39;readline&#39; attributes

Python 报错:TypeError: file must have 'read' and 'readline' attributes 在运行序列化(pickle)相关功能时报错:TypeError: file must have 'read' and 'readline' attributes 上代码: >>> fp = open("a.txt","r+") >>> import pickle >>> pic

python框架Scrapy报错TypeError: &#39;float&#39; object is not iterable解决

原因是:Twisted版本高了. 解决办法: 只要把Twisted库降级到16.6.0即可: 1 pip3 install Twisted==16.6.0 2 3 注:Twisted16.6.0安装后,会自动卸载高版本的Twisted python框架Scrapy报错TypeError: 'float' object is not iterable解决

[转载]UEditor报错TypeError: me.body is undefined

本文转载来自:UEditor报错TypeError: me.body is undefined 今天在使用UEditor的setContent的时候报错,报错代码如下 TypeError: me.body is undefined 或 Uncaught TypeError: Cannot set property 'innerHTML' of undefined 错误的原因是没有等UEditor创建完成就使用UEditor的setContent函数了,可以通过如下代码解决 方法一: uedito

python 报错TypeError: &#39;range&#39; object does not support item assignment,解决方法

贴问题 nums = range(5)#range is a built-in function that creates a list of integers print(nums)#prints "[0,1,2,3,4]" print(nums[2:4])#Get a slice from index 2 to 4 (exclusive); prints '[2,3]" print(nums[2:])#Get a slice from index 2 to the end

Python_报错:SyntaxError: (unicode error) &#39;unicodeescape&#39; codec can&#39;t decode bytes in position 2-3: truncated \UXXXXXXXX escape

Python运行后,报错:SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape 原因:window 读取文件可以用\,但是在字符串中\是被当作转义字符来使用,经过转义之后可能就找不到路径的资源了,例如\t会转义为tab键 上代码: >>> def func1(path_name): ... import os ..

Python_报错:SyntaxError: EOL while scanning string literal

Python_报错:SyntaxError: EOL while scanning string literal 原因:python中,目录操作时,字符串的最后一个字符是斜杠,会导致出错,去掉\即可 上代码 >>> import os >>> os.chdir(r"e:\")#字符串的最后一个字符是斜杠,会导致出错 File "<stdin>", line 1 os.chdir(r"e:\") ^

VUE.JS 使用axios数据请求时数据绑定时 报错 TypeError: Cannot set property &#39;xxxx&#39; of undefined 的解决办法

正常情况下在data里面都有做了定义 在函数里面进行赋值 这时候你运行时会发现,数据可以请求到,但是会报错 TypeError: Cannot set property 'listgroup' of undefined 主要原因是: 在 then的内部不能使用Vue的实例化的this, 因为在内部 this 没有被绑定.可以看下 Stackoverflow 的解释: 解决办法: 1.用ES6箭头函数,箭头方法可以和父方法共享变量 2.在请求axios外面定义一下 var that=this 问题

使用webpack命令打包时,报错TypeError: Cannot read property &#39;presetToOptions&#39; of undefined的解决办法

我只安装了webpack,没有安装webpack-cli,第一次输入webpack打包时,提示 One CLI for webpack must be installed. These are recommended choices, delivered as separate packages: - webpack-cli (https://github.com/webpack/webpack-cli) The original webpack full-featured CLI. We wi

VUE - 使用axios数据请求时数据绑定时 报错 TypeError: Cannot set property &#39;xxxx&#39; of undefined 的解决办法

created() { var that=this axios.get('http://jsonplaceholder.typicode.com/todos') .then(function (res) { // handle success // console.log(res); that.todos = res.data }) .catch(function (error) { // handle error console.log(error); }) .finally(function