have python write to a file code example
Example 1: python write to file
with open("test.txt",'w',encoding = 'utf-8') as f:
f.write("my first file\n")
f.write("This file\n\n")
f.write("contains three lines\n")
Example 2: python write
with open(filename,"w") as f:
f.write('Hello World')