HELLO WORLD--一起加油(🍺|

kingwzun

园龄:3年6个月粉丝:111关注:0

7-9 sdut-字典合并

知识点:

sort函数的排序规则key的使用

代码:

dit1=dict(eval(input()))
dit2=dict(eval(input()))
for i,j in dit1.items():
dit2[i]=dit2.get(i,0)+j
ans=list(dit2.items())
ans.sort(key=lambda x : ord(x[0]) if type(x[0]) == str else x[0])
for i,j in ans:
if(type(i)==str):
print("'{}':{}".format(i,j))
else:
print("{}:{}".format(i,j))

本文作者:kingwzun

本文链接:https://www.cnblogs.com/kingwz/p/16326199.html

版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。

posted @   kingwzun  阅读(142)  评论(0编辑  收藏  举报
点击右上角即可分享
微信分享提示
评论
收藏
关注
推荐
深色
回顶
收起