python open file write line code example Example: python writeline file f = open("test.txt", "w") f.writelines(["Hello", "World"]) f.close