Python修改指定格式文档

#读取两行 删除'卡号:'和 '卡密:'
#保存到数组中 ' ' 隔开然后输出
f = open('E:\\test1.txt')
done = 0
num = []
while not done:
aLine = f.readline().strip().replace('\n','').replace('卡号:','').replace('卡密:','')
num.append(aLine)
if(aLine !=''):
done = 0
else:
done = 1
f.close()
a= 0
try:
while len(num)>=a:
print(num[a] + ' ' + num[a+1])
a = a+2
except Exception as a:
a = ''
print(a)
#这里实在解决不了索引越界异常,只能用用这种方法打马虎眼

猜你喜欢

转载自www.cnblogs.com/Osword/p/9760600.html
今日推荐