参考文档: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‘)
时间: 2024-12-26 02:41:05