Python Write To File Line By Line - /Decoding/Devops
www.decodingdevops.com › python-write-to-file-linePython Write To File Line By Line Using writelines () and For Loop: lines = ['line1', 'line2',"line3"] f=open ('devops.txt', 'a') f.writelines ("%s " % i for i in lines) f.close () here in the first line we defined a list with varaible lines. and in the second line, we are opening the file to append the new lines. and then by using writelines () function we are sending the list to the file line by line. writelines function in python needs a list. so here we are sending list ‘lines’ to ...