返回列表 发帖
本帖最后由 pcl_test 于 2016-4-3 21:17 编辑

举个栗子,字典法
# encoding: UTF-8
from collections import OrderedDict
stem = OrderedDict([('a','1'), ('b','2'), ('c','3')])
jd = ['a 2', 'a 3', 'c 1', 'd 4', 'e 5', 'b 6']
for i in jd:
t = i.split()
if stem.get(t[0]):
stem[t[0]] += '\t' + t[1]
for i, j in stem.items():
print(i+'\t'+j)COPY
3

评分人数

    • CrLf: 666技术 + 1
    • batsealine: 这样实在太快了技术 + 1
    • codegay: 天啊,版主还能写得一手python技术 + 1

TOP

返回列表