python读取txt文件中特定位置字符的方法
时间:2020-11-30 13:29:25|栏目:Python代码|点击: 次
如下所示:
# -*- coding:utf-8 -*- import sys reload(sys) sys.setdefaultencoding('utf8') fp = open("resources.txt", "r") sample = fp.readlines() file=open("test.txt", "w") for line in sample: sample_ = line.split('固定字符') print(sample_[n]) file.write(sample_[n]) file.write('\n')