如下所示:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
# -*- 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' ) |
以上这篇python读取txt文件中特定位置字符的方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持服务器之家。
原文链接:https://blog.csdn.net/weixin_39012047/article/details/81328724