成功解决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,而不是转义为制表符


大功告成!


相关文章
|
NoSQL Linux
gdb调试产生code文件以及遇到的“file format not recognized”问题解决
gdb调试产生code文件以及遇到的“file format not recognized”问题解决
1246 0
成功解决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 =
|
8月前
|
XML 移动开发 Unix
open(file, mode=‘r‘, buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=No
open(file, mode=‘r‘, buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=No
Newline required at end of file but not found.
Newline required at end of file but not found.
225 0
Newline required at end of file but not found.
|
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
251 0
THCudaCheck FAIL file=/pytorch/aten/src/THC/THCGeneral.cpp line=405 error=11 : invalid argument
|
Python
FileNotFoundError: [Errno 2] No such file or directory
FileNotFoundError: [Errno 2] No such file or directory
772 0
FileNotFoundError: [Errno 2] No such file or directory
成功解决OSError: [Errno 22] Invalid argument: ‘checkpoints\20211211.pth.tar‘
成功解决OSError: [Errno 22] Invalid argument: ‘checkpoints\20211211.pth.tar‘
|
存储 Python
python2:open()文件名为中文,报错IOError: [Errno 22] invalid mode ('w') or filename
python2:open()文件名为中文,报错IOError: [Errno 22] invalid mode ('w') or filename
525 0
OSError: image file is truncated (12 bytes not processed) Premature end of JPEG file
OSError: image file is truncated (12 bytes not processed) Premature end of JPEG file
557 0
OSError: cannot write mode P as JPEG
OSError: cannot write mode P as JPEG
620 0

热门文章

最新文章