📜  在 python 代码示例中打开并写入文件

📅  最后修改于: 2022-03-11 14:45:14.943000             🧑  作者: Mango

代码示例2
my_file = open("C:\\Users\\Python\\file.txt", "w")
#Give the path accurately and use \\
my_file.write("This is the test text")
my_file.close()

# It is always recommended to close the file after modifying
# to see the output, open the file - file.txt