【发布时间】:2021-01-25 02:37:40
【问题描述】:
我想建立一个程序来保存一些文档文件。 我的程序在测试文件夹中运行,我想将文档保存在 test\save 中。 我使用这些方式:
File=open("C:\\test\\save\\hello.txt",'w')
File.write("hello world")
File.close()
现在我将我的程序复制到 E 驱动程序并运行该程序,然后在 C 驱动程序而不是 E 驱动程序中生成 hello.txt。 我应该怎么做才能保存超过我的测试文件夹的每个地方的文档??
【问题讨论】:
-
你试过
open("test\\save\\hello.txt",'w')吗? -
确保您的路径正确。无论是驱动器 - C:、E:、D: 等还是您的文件夹。
-
您的意思是:'File=open("\\test\\save\\hello.txt",'w')'?
标签: python python-3.x