如何告诉 Python 在哪里保存文本文件?
例如,我的计算机正在我的桌面上运行 Python 文件。我希望它将所有文本文件保存在我的文档文件夹中,而不是在我的桌面上。在这样的剧本里我该怎么做呢?
name_of_file = raw_input("What is the name of the file: ")
completeName = name_of_file + ".txt"
#Alter this line in any shape or form it is up to you.
file1 = open(completeName , "w")
toFile = raw_input("Write what you want into the field")
file1.write(toFile)
file1.close()