I want to write text files with DOS/Windows line endings \'\\r\\n\' using python running on Linux. It seems to me that there must be a better way than manually putting a \'\\r\\
You could write a function that converts text then writes it. For example:
def DOSwrite(f, text): t2 = text.replace('\n', '\r\n') f.write(t2) #example f = open('/path/to/file') DOSwrite(f, "line 1\nline 2") f.close()