摘要: Python运行后,报错:SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape 原因:window 读取文件可以用\,但是在 阅读全文
posted @ 2018-10-04 23:48 翻滚的小强 阅读(143790) 评论(3) 推荐(9) 编辑
摘要: Python_报错:SyntaxError: unexpected character after line continuation character 原因:写入的文件内容不正确,应处理为字符串 写成这样就ok了:os.chdir(time_year+"\\"+time_month+"\\"+t 阅读全文
posted @ 2018-10-04 18:16 翻滚的小强 阅读(17735) 评论(0) 推荐(0) 编辑
摘要: divmod() 函数 说明:把除数和余数运算结果结合起来,返回一个包含商和余数的元组(a // b, a % b)。 用法:divmod(a,b) 7//2#结果为商 7%2#结果为余数 示例: divmod(7,2) type(divmod(7,2))#返回结果为一个元祖 阅读全文
posted @ 2018-10-04 16:08 翻滚的小强 阅读(3540) 评论(0) 推荐(0) 编辑
摘要: 报错:TypeError: Tuple or struct_time argument required 原因:时间戳——格式化时间 不能直接转换会报错 上代码: import time time3 = time.asctime(time.time())# print ("本地时间为 :",time 阅读全文
posted @ 2018-10-04 15:57 翻滚的小强 阅读(36968) 评论(0) 推荐(0) 编辑
摘要: time模块 time.time() 返回当前时间的时间戳(1970纪元后经过的浮点秒数) 1、简单运用 import time time.time()#查看当前时间,结果为时间戳 time.localtime()#查看当前本地时间,结果为时间元祖 2、简单转换 (1)时间元祖——时间戳 time. 阅读全文
posted @ 2018-10-04 15:50 翻滚的小强 阅读(1272) 评论(0) 推荐(0) 编辑
摘要: 文件写入操作时,报错:TypeError: write() argument must be str, not list 原因:python写入的内容要是字符串类型的 上代码: fp = open("a.txt","w")fp.write([1,2,3])fp.close() 写入内容为字符串类型则 阅读全文
posted @ 2018-10-04 14:29 翻滚的小强 阅读(6245) 评论(0) 推荐(0) 编辑