Answers for "python open write no newline"

3

python writelines newline

lines = ['line1', 'line2']
with open('filename.txt', 'w') as f:
    f.writelines("%s\n" % l for l in lines)
Posted by: Guest on October-19-2020
3

python read file without newline

# converts read file into a list without newlines
temp = file.read().splitlines()
Posted by: Guest on April-15-2020

Python Answers by Framework

Browse Popular Code Answers by Language