open()函数无法打开桌面TXT文件
本帖最后由 xiaoyuer000 于 2021-11-27 10:49 编辑桌面创建TXT文件 open()函数无法打开 本帖最后由 jackz007 于 2021-11-26 22:02 编辑
把 open() 里的文件名改成"sss.txt.txt" , Windows 资源器在默认情况下开启了 "不显示已知类型文件扩展名" 的选项,使得一个看上去是 "sss.txt" 的文件名实际上是 "sss.txt.txt" jackz007 发表于 2021-11-26 22:00
把 open() 里的文件名改成"sss.txt.txt" , Windows 资源器在默认情况下开启了 "不显示已知类型 ...
f = open(r"C;\Users\goodb\Desktop\sss.txt.txt")
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
f = open(r"C;\Users\goodb\Desktop\sss.txt.txt")
FileNotFoundError: No such file or directory: 'C;\\Users\\goodb\\Desktop\\sss.txt.txt'
xiaoyuer000 发表于 2021-11-26 22:11
f = open(r"C;%users\goodb\Desktop\sss.txt.txt")
Traceback (most recent call last):
File "", li ...
r"C;\Users\goodb\Desktop\sss.txt.txt"
看出问题了? 错把引号当冒号 jackz007 发表于 2021-11-26 22:17
r"C;%users\goodb\Desktop\sss.txt.txt"
看出问题了?
f = open(r"C:Users\goodb\Desktop\sss.txt.txt")
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
f = open(r"C:Users\goodb\Desktop\sss.txt.txt")
FileNotFoundError: No such file or directory: 'C:Users\\goodb\\Desktop\\sss.txt.txt' 列斗 发表于 2021-11-26 22:19
错把引号当冒号
f = open(r"C:Users\goodb\Desktop\sss.txt.txt")
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
f = open(r"C:Users\goodb\Desktop\sss.txt.txt")
FileNotFoundError: No such file or directory: 'C:Users\\goodb\\Desktop\\sss.txt.txt'
改了也找不到桌面文件 你还得试试 "sss.txt" 啊,这个也得教吗? f = open(r"C:\Users\goodb\Desktop\sss.txt.txt")
Traceback (most recent call last):
File "<pyshell#7>", line 1, in <module>
f = open(r"C:\Users\goodb\Desktop\sss.txt.txt")
FileNotFoundError: No such file or directory: 'C:\\Users\\goodb\\Desktop\\sss.txt.txt' xiaoyuer000 发表于 2021-11-26 22:31
f = open(r"C:Users\goodb\Desktop\sss.txt.txt")
Traceback (most recent call last):
File "", li ...
f = open(r"C:\Users\goodb\Desktop\sss.txt")
试一下这个 C:\Users\Administrator\Desktop\record.txt
谢谢大家问题找到了 新创建文件地址输入错误
f = open(r"C:\Users\Administrator\Desktop\record.txt")
>>> f
<_io.TextIOWrapper name='C:\\Users\\Administrator\\Desktop\\record.txt' mode='r' encoding='cp936'> 列斗 发表于 2021-11-26 23:25
试一下这个
C:\Users\Administrator\Desktop\record.txt
谢谢大家问题找到了 新创建文件地址输入错误
f = open(r"C:\Users\Administrator\Desktop\record.txt")
>>> f
<_io.TextIOWrapper name='C:\\Users\\Administrator\\Desktop\\record.txt' mode='r' encoding='cp936'> 用户文件夹。。。
页:
[1]