Python: Write to File
To open a file and write to it, do:
import sys # 'w' for write (overwrite exsiting file), 'a' for append xfile = open("c:/Users/xah/x126238.html", "w", encoding="utf-8") xfile.write("hello\n") xfile.close() print("done")
To open a file and write to it, do:
import sys # 'w' for write (overwrite exsiting file), 'a' for append xfile = open("c:/Users/xah/x126238.html", "w", encoding="utf-8") xfile.write("hello\n") xfile.close() print("done")