标签:
python读取文件,如何去掉每一行末尾的换行符"\n"
参考文档:http://blog.csdn.net/jfkidear/article/details/7532293
#!/usr/bin/python # coding:utf-8 # 文件操作 with open(‘~/refer.txt‘, ‘r‘) as f: print(‘文件正常打开,正在开始操作文件‘) for line in f.readlines(): # python按行读取文件,如何去掉换行符"\n" print line.strip(‘\n‘)
标签:
原文地址:http://my.oschina.net/repine/blog/530568