write file python line by line code example
Example 1: python writeline file
f = open("test.txt", "w")
f.writelines(["Hello", "World"])
f.close
Example 2: python writeline file
f = open("test.txt", "w")
f.write("Hello \nWorld")
f.close
Example 3: print file line by line python
with open('yourfile.txt','r') as f:
lines = f.readlines()
f.close()