Python 2.7.1 (r271:86832, Nov 27 2010, 18:30:46) [MSC v.1500 32 bit (Intel)] onwin32Type "help", "copyright", "credits" or "license" for more information.>>> import os>>> os.linesep'\r\n'>>> f = open('myfile','w')>>> f.write('hi there\n')>>> f.write('hi there' + os.linesep) # same result as previous line ?????????>>> f.close()>>> open('myfile', 'rb').read()'hi there\r\nhi there\r\r\n'>>>
import time
start = start = time.time()with open("test.txt", 'w') as f:for i in range(10000000):# print('This is a speed test', file=f)# f.write('This is a speed test\n')end = time.time()print(end - start)