在使用python语言的open函数时,提示错误OSError: [Errno 22] Invalid argument: ‘文件路径’
来源:互联网 发布:喜马拉雅fm电脑mac版 编辑:程序博客网 时间:2024/06/01 08:43
如题,在使用python语言的open函数时,提示错误OSError: [Errno 22] Invalid argument: ‘文件路径’,在查阅了大量资料后也得到了一些解决方案,但是这些解决方案对于作者的情况都不适用,依然报错,没办法,虽然作者的英语水平很不咋地,但中文帮不了作者,只好求助于英文了。
建议各位看客在修改时,仔细看清楚自己的情况是否适用。废话不多说,开始正文。
作者的路径为open(‘D:\LearningBooks\test.txt’)
在使用时报错是因为这个路径是直接从Windows的文件目录里复制过来的,在python中\是转义字符,作者文件中的\test.txt中,\t是制表字符,要想正常使用路径需要改成如下形式D:\LearningBooks\\test.txt
或者D:/LearningBooks/test.txt即直接用斜杠/不用反斜杠\。
这一点其实在多个语言中都很重要,写下此文主要是提醒自己一定要注意路径的书写规范。
阅读全文
2 0
- 在使用python语言的open函数时,提示错误OSError: [Errno 22] Invalid argument: ‘文件路径’
- python打开文件报错OSError: [Errno 22] Invalid argument:
- OSError: [Errno 22] Invalid argument:
- PHP使用copy函数复制windows文件时出现failed to open stream: Invalid argument in错误
- setsockopt invalid argument,errno 22
- 错误提示:accept: Invalid argument
- python open() 打开文件出现 IOError: [Errno 22] invalid mode ('r') or filename:
- shmget创建共享内存errno=22,Invalid argument错误问题
- pefile under python 2.4 (centos os ) EnvironmentError: [Errno 22] Invalid argument
- accept的Invalid Argument错误
- red5的invalid argument错误
- select函数的错误,Invalid argument 或 Bad file descriptor
- 消息队列函数 msgsnd 出现Invalid argument错误的解决办法
- 解决DPDK脚本python执行时“OSError: [Errno 2] No such file or directory”的问题
- mac下更新pip时提示OSError: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/pip-8.0.2-py2.
- python IOError: [Errno 22] invalid mode ('r') or filename;错误的处理方法
- python3 使用pyaudio OSError: [Errno -9996] Invalid input device (no default output device)-ubuntu16.04
- sendto 返回-1,errno为22,invalid argument的解决办法,mark一下
- JAVA多线程之wait/notify
- leetcode_Hamming Distance
- reset.css
- Android 发送自定义广播
- Java-FileUploadUtil工具类
- 在使用python语言的open函数时,提示错误OSError: [Errno 22] Invalid argument: ‘文件路径’
- JAVA学习笔记-----面向对象
- Oracle 登录指令
- 打开一个网址需要经过的步骤
- List,Set,Map用法以及区别
- snprintf函数用法
- Java-FileUtil工具类
- JS事件、JS API
- 深圳物业满意度研究:标杆房企持续加码满意度管理