一个简单的Python字符串处理文件
#!/usr/bin/env python3
import re
def lineprocess(line):
res = ''
index = 47
if line[index] == 'e':
index = index+2
if line[index] == '=':
index = index+1
while True:
if line[index] == 'm':
break
res = res+line[index]
index = index+1
return res
def main():
index = 1
text = open('data.txt', "r") # open()
for line in text.readlines(): # readlines()
res = lineprocess(line) # res => str
#print(('%d '+res) % index)
print(res)
index = index+1
if __name__ == '__main__':
main()
2017/3/6
To improve is to change, to be perfect is to change often.