如何告訴Python保存文本文件的位置?告訴Python將.txt文件保存到Windows和Mac上的某個目錄中
例如,我的電腦在我的桌面上運行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()
感謝您的幫助 – user1031493