# -*- coding:utf-8 -*-
import os
# python写文件换行问题
def write_file():
out_file = open("test1.txt", 'w')
line = "hello world"
out_file.write(line+'\n')
line = "hello world"
out_file.write(line+'\n')
def write_file_2():
out_file = open("test2.txt", 'w')
line = "hello world"
line += os.linesep
out_file.write(line)
line = "hello world"
line += os.linesep
out_file.write(line)
if __name__ == '__main__':
write_file()
write_file_2()
两次写入文件的内容不一样,write_file_2每行多了一次换行