python文件操作的坑( FileNotFoundError: [Errno 2] No such file or directory...)
环境:Windows8.1, Python3.6 pycharm community 2017
with open('c:\\setup','r') as f:
f.read()
提示一直很诡异:FileNotFoundError: [Errno 2] No such file or directory: 'c:\\setup'
网上有大量关于Python编码错误导致无法打开文件的解决方法,utf8 gbk2312,尝试过一遍全部无效
最后原因很乌龙:setup后缀是*.log
换成
filename = 'c:\\setup.log'
所有问题解决
PS:所有Windows下的文件路径,一律用双反斜杠
python文件操作的坑( FileNotFoundError: [Errno 2] No such file or directory...)的更多相关文章
- Python中的用open打开文件错误,FileNotFoundError: [Errno 2] No such file or directory:
学习python的文件处理,刚开始打开文件,代码如下 f = open('test_file.txt', 'r', encoding='UTF-8')RES = f.readlines()print( ...
- 关于python中的 “ FileNotFoundError: [Errno 2] No such file or directory: '……'问题 ”
今天在学python时,在模仿一个为图片加上图标并移动到指定文件夹的程序时遇到“FileNotFoundError: [Errno 2] No such file or directory: '152 ...
- 关于JPype报FileNotFoundError: [Errno 2] No such file or directory: '/usr/lib/jvm'错误的解决
部署到线上的项目正常运行一年,今天早上突然报FileNotFoundError: [Errno 2] No such file or directory: '/usr/lib/jvm'错误. JPyp ...
- FileNotFoundError: [Errno 2] No such file or directory: 'image/1.jpg'问题解决
FileNotFoundError: [Errno 2] No such file or directory: 'image/1.jpg'问题 最近在学习爬虫,想爬一些图片并保存到本地,但是在下载图片 ...
- 对于python中“FileNotFoundError: [Errno 2] No such file or directory”的解决办法
在我们使用vscode运行Python代码时遇到的情况 一.出现原因:这里是由于Vscode中,python里的路径是相对与工作目录来进行定位的.所以在多级目录情况下,若不设置绝对路径,往往找不到相应 ...
- FileNotFoundError: [Errno 2] No such file or directory的解决方法
1.获取当前文件所在路径 basedir = os.path.dirname(__file__) print("basedir:" + basedir) 2.将路径进行拼接 upl ...
- python3 使用selenium +webdriver打开chrome失败,报错:FileNotFoundError: [Errno 2] No such file or directory: 'chromedriver': 'chromedriver'
提示chrome driver没有放置在正确的路径下 解决方法: 1.chromedriver与chrome各版本及下载地址 驱动的下载地址如下: http://chromedriver.storag ...
- Python文件操作之把臂入林
文件操作1.打开文件open(file, mode='r', buffering=None, encoding=None, errors=None, newline=None, closefd=Tru ...
- Python 文件操作(1)
今天大佬给了个A文件给我,里面存放了机密数据. 什么机密数据??? 有帅哥的联系方式吗? 赶紧打开来看一下 1.open() 函数基本版 Python大佬有个内置开文件的函数open(), 专门开文件 ...
随机推荐
- datatables如何让某个列中的值居中显示?
https://datatables.net/reference/option/columns.className 通过 columns.className 属性设置: 例如: js: columns ...
- mysql格式化日期的函数
转自:https://www.cnblogs.com/duhuo/p/5650876.html mysql格式化日期 mysql查询记录如果有时间戳字段时,查看结果不方便,不能即时看到时间戳代表的 ...
- Feature Tools 简介
FeatureTools是2017年9月上线的github项目,是一个自动生成特征的工具,应用于关系型数据. github链接:https://github.com/Featuretools/feat ...
- 'Settings' object has no attribute 'TEMPLATE_DEBUG' 的解决方法
找到该Django项目下的settings文件,把 DEBUG = True 改为 DEBUG = False 就可以正常浏览显示了 参考:https://stackoverflow.com/ques ...
- chorme快捷键
Chrome窗口和标签页快捷键:Ctrl+N 打开新窗口 Ctrl+T 打开新标签页 Ctrl+Shift+N 在隐身模式下打开新窗口 Ctrl+O,然后选择文件 在谷歌浏览器中打开计算机上的文件 按 ...
- Apache的配置详解,最好的Apache配置文档
http://blog.csdn.net/apple_llb/article/details/50253889 Apache的配置由httpd.conf文件配置,因此下面的配置指令都是在httpd.c ...
- 8.ajax查询数据
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <m ...
- X-UA-Compatible也无法解决的IE11兼容问题
3月8日接到一位用户的电话,说写博客时编辑器显示不出来.浏览器用的是披着360外衣的IE11,编辑器用的是CuteEditor. 当时电脑上没安装IE11,用IE10测试正常,心想应该是一个手到擒来的 ...
- 系统中同时有 python2和 python3,怎么让 ipython 选择不同的版本启动?
已经安装的情况下: > which ipython /usr/local/bin/ipython > cat /usr/local/bin/ipython #!/usr/local/op ...
- spring boot由浅入深(二)spring boot基本命令及操作
一 spring常见注解 @RestController和@RequestMapping说明: @RestController.这被称为一个构造型(stereotype)注解.它为阅读代码的人们提供建 ...