Avoid writing carriage return '\\r' when writing line feed with Python
If taken into consideration that carriage return = \r and line feed = \n Python 3.5.1 (v3.5.1:37a07cee5969, Dec 6 2015, 01:38:48) [MSC v.1900 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> '{:02x}'.format(ord('\n')) '0a' >>> '{:02x}'.format(ord('\r')) '0d' how to avoid writing carriage return when using open('filename','w').write('text\n') ? In interactive mode you can do this: >>> open('filename','w').write('text\n') 5 >>> for c in open('filename','r').read(): ... print('{:02x}'.format(ord(c))) ... 74 65 78 74 0a This would indicate that