为什么用Python不能正常打开文件??总是Errno22 Invalid argument: '\u202aD:\\...
file:///C:/Users/44461/OneDrive/%E5%9B%BE%E7%89%87/%E5%B1%8F%E5%B9%95%E5%BF%AB%E7%85%A7/2020-08-07%20(1).png各位大料求帮助
>>> f = open('E:\\kd.docx')
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
f = open('E:\\kd.docx')
OSError: Invalid argument: '\u202aE:\\kd.docx'
>>> f = open('D:\\kd.docx')
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
f = open('D:\\kd.docx')
OSError: Invalid argument: '\u202aD:\\kd.docx'
>>> f
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
f
NameError: name 'f' is not defined
>>> f = open('D:\\dkk.txt')
Traceback (most recent call last):
File "<pyshell#3>", line 1, in <module>
f = open('D:\\dkk.txt')
OSError: Invalid argument: '\u202aD:\\dkk.txt' 本帖最后由 zltzlt 于 2020-8-7 09:01 编辑
把前面的 特殊符号去掉。可以参考:https://blog.csdn.net/qq_33733970/article/details/77519660
这些字符去掉然后这样打开试试看?
f = open(r'E:\kd.docx') f = open("E:\kd.docx")
页:
[1]