Chinaunix
标题:
python字典处理案例
[打印本页]
作者:
ma3501406
时间:
2018-01-16 11:34
提示:
作者被禁止或删除 内容自动屏蔽
作者:
jason680
时间:
2018-01-16 11:57
回复
1#
ma3501406
http://bbs.chinaunix.net/thread-4290275-1-1.html
作者:
zxy877298415
时间:
2018-01-16 16:06
本帖最后由 zxy877298415 于 2018-01-16 16:17 编辑
回复
1#
ma3501406
python 3
import re
with open ('file.txt') as f,open ('file1.txt') as f1:
l=f1.readlines()
s = 0
for i in f:
t=re.split(' +',i)
for j in range(0,11-int(t[1])):
if s == len(l):break
print (t[0]+" "+l[s], end='')
s += 1
复制代码
欢迎光临 Chinaunix (http://bbs.chinaunix.net/)
Powered by Discuz! X3.2