成功解决fp = builtins.open(filename, "rb") OSError: [Errno 22] Invalid argument: 'F:\\File_Pyt

简介: 成功解决fp = builtins.open(filename, "rb") OSError: [Errno 22] Invalid argument: 'F:\\File_Pyt

解决问题


fp = builtins.open(filename, "rb")

OSError: [Errno 22] Invalid argument:

'F:\\File_Python\\Python_example\x0cast_style_transfer_master\\examples\\content\x8180214(1).jpg'



解决思路


操作系统错误:[errno 22]无效参数:




解决方法


在指定路径前边加上r即可,禁止字符串转义  

1、案例理解

   a = r'test\tddd'

   b= 'test\tddd'

   print(a)

   print(b)

输出结果是:

test\tddd

test    ddd

其中s里面的\t就是使用真实字符\t,而不是转义为制表符


大功告成!


相关文章
成功解决OSError: Unable to open file (truncated file: eof = 8388608, sblock->base_addr = 0, stored_eof =
成功解决OSError: Unable to open file (truncated file: eof = 8388608, sblock->base_addr = 0, stored_eof =
成功解决OSError: Unable to open file (truncated file: eof = 8388608, sblock->base_addr = 0, stored_eof =
|
4月前
|
DataWorks Linux API
“Invalid folder
“Invalid folder
43 2
|
PyTorch 算法框架/工具
THCudaCheck FAIL file=/pytorch/aten/src/THC/THCGeneral.cpp line=405 error=11 : invalid argument
THCudaCheck FAIL file=/pytorch/aten/src/THC/THCGeneral.cpp line=405 error=11 : invalid argument
125 0
THCudaCheck FAIL file=/pytorch/aten/src/THC/THCGeneral.cpp line=405 error=11 : invalid argument
Argument 2 passed to think\\filesystem\\Driver::putFile() must be an instance of think\\File
Argument 2 passed to think\\filesystem\\Driver::putFile() must be an instance of think\\File
1066 0
成功解决OSError: [Errno 22] Invalid argument: ‘checkpoints\20211211.pth.tar‘
成功解决OSError: [Errno 22] Invalid argument: ‘checkpoints\20211211.pth.tar‘
|
机器学习/深度学习
成功解决NotFoundError (see above for traceback): Failed to create a directory: ; No such file or directo
成功解决NotFoundError (see above for traceback): Failed to create a directory: ; No such file or directo
|
Python
FileNotFoundError: [Errno 2] No such file or directory
FileNotFoundError: [Errno 2] No such file or directory
604 0
FileNotFoundError: [Errno 2] No such file or directory
|
存储 Python
python2:open()文件名为中文,报错IOError: [Errno 22] invalid mode ('w') or filename
python2:open()文件名为中文,报错IOError: [Errno 22] invalid mode ('w') or filename
406 0
OSError: cannot write mode P as JPEG
OSError: cannot write mode P as JPEG
460 0

热门文章

最新文章