python按行读取文件,如何去掉换行符"\n

如题所述

for line in file.readlines():

line=line.strip('\n')

这里使用了strip去掉每行结束的\n
温馨提示:答案为网友推荐,仅供参考
相似回答