环境:Windows8.1, Python3.6 pycharm community 2017
1 with open(‘c:\\setup‘,‘r‘) as f: 2 f.read()
提示一直很诡异:FileNotFoundError: [Errno 2] No such file or directory: ‘c:\\setup‘
网上有大量关于Python编码错误导致无法打开文件的解决方法,utf8 gbk2312,尝试过一遍全部无效
最后原因很乌龙:setup后缀是*.log
换成
1 filename = ‘c:\\setup.log‘
所有问题解决
python文件操作的坑( FileNotFoundError: [Errno 2] No such file or directory...)
原文:http://www.cnblogs.com/fanyuchen/p/7073629.html