Python报错IOError: [Errno 22] invalid mode ('r') or filename
来源:互联网 发布:atmega dip封装单片机 编辑:程序博客网 时间:2024/05/16 05:01
IOError: [Errno 22] invalid mode (‘r’) or filename:
这种错误的出现是在使用built-in函数file()或者open()的时候。
或者是因为文件的打开模式不对,或者是文件名有问题。
前者的话只需要注意文件是否可读或者可写就可以了。
后者则是与文件路径相关的问题,需要在文件名前加r或者R转义,如:file(r”e:\Test.txt”,’r’).或者将反斜杠\变成两个,如file(“e:\Test.txt”,’r’).
PS:在重命名rename(‘FilePath1’, ‘FilePath2’)和和删除文件remove(‘FilePath1’, ‘FilePath2’)的时候,要注意,“FilePath1”和“FilePath2”都需要文件的绝对路径,不然文件是Python的默认的路径——“D:\Software\python\Python27”(在我的电脑上的路径)
阅读全文
1 0
- Python报错IOError: [Errno 22] invalid mode ('r') or filename
- Python:[转]IOError: [Errno 22] invalid mode ('r') or filename:
- IOError: [Errno 22] invalid mode ('r') or filename
- python open() 打开文件出现 IOError: [Errno 22] invalid mode ('r') or filename:
- python IOError: [Errno 22] invalid mode ('r') or filename;错误的处理方法
- python IOError: invalid mode ('r') or filename
- IOError: [Errno 22] invalid mode ('r') or filename;错误的处理方法
- IOError: [Errno 22] invalid mode ('r') or filename;错误的处理方法
- IOError: [Errno 22] invalid mode ('r') or filename;错误的处理方法
- IOError: [Errno 22] invalid mode ('w') or filename;
- python中用open打开文件,报错 IOError:[Error 22] invalid mode ('rb') or filename
- Python打开文件出现IOError: [Errno 22] invalid mode ('rb') or filename
- python做工具遇到报错:[Errno 22] invalid mode ('rb') or filename
- 【Python】按行读取文件、IOError: [Errno 22] invalid mode ('a+') or filename,处理文件的换行符
- [Errno 22] invalid mode ('r') or filename: 'E:\\python\\website\\djangoweb\t
- django安装报错error: [Errno 22] invalid mode ('wb') or filename:
- Python tarfile模块解压报错 invalid mode ('wb') or filename
- [Python]Invalid mode ('w') or filename: 'd:\x0bideo'
- c#匿名类与匿名函数、lambda表达式
- Redis源码剖析-链表list
- windows 命令行解析
- 原生js分页功能
- flowable 五个引擎和组成引擎的服务
- Python报错IOError: [Errno 22] invalid mode ('r') or filename
- sping boot 打war 包 在tomcat 中运行
- Linux命令大全
- Java内存区域
- Elasticsearch 数据搜索篇·【入门级干货】
- PPT控件 Spire.Presentation for .NET V2.8.35发布 | 支持设置演示幻灯片布局
- jQuery中event.stopPropagation()阻止事件冒泡及event.preventDefault()阻止默认行为
- adaboost学习(三)
- 线程安全性