how to write to file in pyt] code example
Example 1: python write file
with open("file.txt", "w") as file:
for line in ["hello", "world"]:
file.write(line)
Example 2: 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")