上一页 1 ··· 7 8 9 10 11 12 13 下一页
摘要: 精度问题 不正确 >>> 10-9.90.09999999999999964 需要处理 >>> (10*100-9.9*100)/1000.1 阅读全文
posted @ 2018-10-06 22:21 翻滚的小强 阅读(259) 评论(0) 推荐(0) 编辑
摘要: 一、编码转换py2和py3对中文的处理 py2: 1 文件要存为utf-8 2 文件第一行声明为:#encoding=utf-8 #coding=utf-8 #coding:utf-8 #_*_coding:UTF-8_*_ 3 所有的中文前面加u,表示unicode py3: 1 文件要存为utf 阅读全文
posted @ 2018-10-06 16:56 翻滚的小强 阅读(11069) 评论(0) 推荐(1) 编辑
摘要: 列出所有关键字 作用:避免因命名冲突而引发异常错误 import keyword keyword.kwlist 简单应用 判断是否为关键字 keyword.iskeyword("break") keyword.iskeyword("breaka") 阅读全文
posted @ 2018-10-05 23:27 翻滚的小强 阅读(1361) 评论(0) 推荐(0) 编辑
摘要: os.path.splitext(path) 说明:将对应路径的文件名和后缀名分割 示例: 简单运用:统计整个e盘下,txt文件的总数 其中os.walk()的简单说明,请参照:python中:os.walk()的简单说明 上面的方法等价于: 阅读全文
posted @ 2018-10-05 21:20 翻滚的小强 阅读(12929) 评论(0) 推荐(0) 编辑
摘要: shutil 模块 import os os.chdir("/home/test") os.system("cp /home/wxh/a.txt ./b.txt") shutil复制文件(必须在文件里面操作) import shutil shutil.copyfile("/home/wxh/a.tx 阅读全文
posted @ 2018-10-05 19:27 翻滚的小强 阅读(243) 评论(0) 推荐(0) 编辑
摘要: os.walk() os.walk(top,topdown=True,onerror=None,followlinks=False) 参数说明: top:遍历哪个目录 topdown:先返回文件还是目录,默认值为false,先遍历子目录,再返回子目录的文件 onerror:出现错误时怎么处理,按默认 阅读全文
posted @ 2018-10-05 16:27 翻滚的小强 阅读(1447) 评论(0) 推荐(0) 编辑
摘要: Python_报错:SyntaxError: EOL while scanning string literal 原因:python中,目录操作时,字符串的最后一个字符是斜杠,会导致出错,去掉\即可 上代码 解决方法:去掉最后的\即可 阅读全文
posted @ 2018-10-05 15:15 翻滚的小强 阅读(67037) 评论(0) 推荐(0) 编辑
摘要: 1、目录的新建import osos.mkdir(r"001\002\003") 2、判断目录是否存在import osos.path.exists(r"001\002\003") 3、删除目录import osos.removedirs(r"001\002\003") 阅读全文
posted @ 2018-10-05 00:06 翻滚的小强 阅读(183) 评论(0) 推荐(0) 编辑
摘要: 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) 编辑
上一页 1 ··· 7 8 9 10 11 12 13 下一页