小编Big*_*gen的帖子

在python 3.6与旧版本中的字典顺序

我有这些代码,我需要按照这个确切的顺序打印出来(访客团队,访客评分,主页团队,家庭评级,预期获胜者,保证金)tabulate.

final_dict = {'Visitor Team': visitor_team, 'Visitor Rating': visitor_rating, 'Home Team': home_team,
              'Home Rating': home_rating, 'Expected Winner': expected_winner, 'Margin': expected_winner_diff}

print(tabulate(final_dict, headers="keys", floatfmt=".2f", tablefmt="fancy_grid"))
Run Code Online (Sandbox Code Playgroud)

我一直在学习和使用Python 3.6,而且我不知道,3.6中的dicts现在已经订购了,所以这实际上按照我的意图打印出来.这只是愚蠢的运气我想Python 3.6给了我我所需要的!

但我去另一台计算机上安装Python 3.5,这不会像我想的那样打印出来.我一直在阅读有关订单,但我不确定如何使用它.我是否需要首先将final_dict声明为空,然后迭代到我需要的关键顺序?

python dictionary python-3.x python-3.5 python-3.6

3
推荐指数
1
解决办法
555
查看次数

标签 统计

dictionary ×1

python ×1

python-3.5 ×1

python-3.6 ×1

python-3.x ×1