<p>如何告诉Python在哪里保存文本文件?</p>
<p>例如,我的计算机正在桌面上运行Python文件。我希望它将所有文本文件保存在“文档”文件夹中,而不是桌面上。在这样的剧本里我该怎么做?</p>
<pre><code>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()
</code></pre>