小白紧急求助
本帖最后由 富富猪猪 于 2020-12-13 23:23 编辑问题:如何在例如91-1-1 前加19(年份)想让它变成1991
import re
f=open('C:\\Users\\富富\\Desktop\\编程\\transaction_record_A.txt','r')
lines=f.readlines()
dic_all = dict()
s1='20'
s2='19'
for line in lines:
key,value = re.split(r',',line)
dic_all = value
Line=list(line)
if Line==0:
sorted_key = sorted(dic_all)
for k in sorted_key:
print(k,dic_all,end = ''
(文件传不上来,复制一部分··)
95-1-22,44897.58
95-1-9,35993.82
95-1-20,-27547.44
95-1-24,39950.15
95-1-27,-18536.46
95-2-2,27597.66
95-2-3,7279.21
95-2-4,-43875.77
95-2-9,-35450.48
95-2-11,33233.40
95-3-5,-6192.16
95-3-8,-37008.02
95-3-10,-12431.98
95-3-14,-33039.96
95-3-27,22640.97
95-4-12,-39023.24
只有19吗?
print('19'+k,dic_all,end = '') 用正则表达式啊,查找到了以后添加就行了 不是很明白 逃兵 发表于 2020-12-14 08:20
只有19吗?
还有20···
页:
[1]