小编Tan*_*edi的帖子

Python - 如何解决 OSError: [Errno 22] Invalid argument

我正在学习 python 中的文件对象,但每当我尝试打开文件时,它都会显示以下错误。

我已经检查过该文件位于同一目录中并且存在,仅当我将文件命名为测试时才会发生此错误,如果我使用任何其他名称,则它可以正常工作,这是我的代码

f = open('C:\\Users\Tanishq\Desktop\python tutorials\test.txt', 'r')
Run Code Online (Sandbox Code Playgroud)

这是错误

  Traceback (most recent call last):
  File "C:/Users/Tanishq/Desktop/question.py", line 1, in <module>
  f = open('C:\\Users\Tanishq\Desktop\python tutorials\test.txt', 'r')
  OSError: [Errno 22] Invalid argument: 'C:\\Users\\Tanishq\\Desktop\\python   
  tutorials\test.txt'
Run Code Online (Sandbox Code Playgroud)

python file invalid-argument

8
推荐指数
1
解决办法
8万
查看次数

标签 统计

file ×1

invalid-argument ×1

python ×1