【发布时间】:2019-04-06 12:16:29
【问题描述】:
我是 python 新手。我已经尝试了教程和教科书中可用的所有技术来通过 python shell 打开一个已经存在的文件,它总是返回一种形式的错误或另一种。
test_file = open('C:\Users\User\Documents\test.txt')
复制评论:
Traceback (most recent call last): File "<pyshell#48>", line 1, in <module> see_file = open('Arrows') FileNotFoundError: [Errno 2] No such file or directory: 'Arrows' test_file = open('C:\Users\User\Documents\test.txt') SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape
【问题讨论】:
-
"FileNotFoundError:":您的文件
'Arrows'的扩展名可能类似于'.JPG',或者不在当前工作目录中。 -
是的,它有一个扩展名“.py”。但它在当前工作目录中。
-
感谢您的观察,我现在已经解决了问题
标签: python path python-unicode