Telling Python to save a .txt file to a certain directory on Windows and Mac

后端 未结 7 1167
无人共我
无人共我 2020-11-28 19:55

How do you tell Python where to save a text file?

For example, my computer is running the Python file off my desktop. I want it to save all the text file in my docum

相关标签:
7条回答
  • 2020-11-28 20:40

    Another simple way without using import OS is,

    outFileName="F:\\folder\\folder\\filename.txt"
    outFile=open(outFileName, "w")
    outFile.write("""Hello my name is ABCD""")
    outFile.close()
    
    0 讨论(0)
提交回复
热议问题