python3 for循环字典
可能重复:python3 for循环字典,python,python-3.x,Python,Python 3.x,可能重复: 写这些东西的更好方法是什么?我是被介绍给这些代码的,但我不习惯这样看它们: (alla,allc,) = (set(s) for s in zip(*animaldictionary.keys())) 你还能怎么写这个 print('\n'.join(['\t'.join((c,str(sum(animaldictionary.get(ac,0) for a in alla for ac in ((a,c,),))//12))) for
写这些东西的更好方法是什么?我是被介绍给这些代码的,但我不习惯这样看它们:
(alla,allc,) = (set(s) for s in zip(*animaldictionary.keys()))
你还能怎么写这个
print('\n'.join(['\t'.join((c,str(sum(animaldictionary.get(ac,0)
for a in alla
for ac in ((a,c,),))//12)))
for c in sorted(allc)]))
一旦我回到家,我会用一个更全面(不是双关语)的结果来更新我的答案,并且有更多的时间来理解这些有趣的理解。现在,您需要查看以下内容: