logo

txt读写问题:调用以下函数,写在TXT里面的东西没有换行,请问为什么?

2018-11-15 23:06
Z
rgim

@kidswong999

def write():
w=open('data_base.txt','a')
te=str(temp_L_0[0])+' '+str(temp_L_0[1])+' '+str(temp_L_0[2])+'\n'
w.write(te)
w.write('\n')
print(te)
print('\n')
w.close()
2018-11-16 12:01
I
网红小智智 星瞳科技

用\r\n

不同的操作系统不一样。Windows, Linux, MacOS,是不一样的。

https://cn.bing.com/search?q=%5Cr%5Cn%20%E5%9B%9E%E8%BD%A6%E6%8D%A2%E8%A1%8C&qs=n&form=QBRE&sp=-1&pq=%5Cr%5Cn%20hui%20che%E6%8D%A2%E8%A1%8C&sc=0-14&sk=&cvid=23F92C322934440EAC86060470410A14