我是python新手。我尝试过教程和教科书中提供的所有技术,通过pythonshell打开一个已经存在的文件,它总是返回一种形式的错误。在
test_file = open('C:\Users\User\Documents\test.txt')
Copy comment:
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
这就可以了,你需要用
\
来转义特殊字符,比如\
如果打开是指加载文件:
相关问题 更多 >
编程相关推荐