【发布时间】:2020-02-27 21:10:48
【问题描述】:
您好,我是学习 python 的新手,我正在学习 python 文件处理。 以下代码工作正常。但是我找不到 python 创建这个文件的文件夹。 (我正在使用 Visual Studio 代码)
f = open("demofile2.txt", "a")
f.write("Now the file has new content ")
f.close()
f = open("demofile2.txt", "r")
print(f.read())
【问题讨论】:
-
你检查过运行python脚本的文件夹吗?
-
"文件是一个类似路径的对象,给出了路径名(绝对或相对于当前工作目录)" - 在发布之前,您应该始终阅读docs for the code you're using。
标签: python file location file-handling