This code snippet shows how to write to a file. The "w" file mode opens a file for writing only. Overwrites the file if the file exists. If the file does not exist, creates a new file for writing.
file = open("file.txt", "w")
file.write("Hello world")
file.close()
No comments:
Post a Comment