这是我的字典
x = {'balance': 19.1, 'advance': 0.4, 'withdrawal': 53.0, 'deposit': 24.7, 'transfer': 2.8000000000000003}
当我尝试按
排序时sorted(x) = ['advance', 'balance', 'deposit', 'transfer', 'withdrawal']
它只给了我钥匙,我还需要相应的值
答案 0 :(得分:0)
x = {'balance': 19.1, 'advance': 0.4, 'withdrawal': 53.0, 'deposit': 24.7, 'transfer': 2.8000000000000003}
print [i for i in sorted(x.items())]
输出:[('advance', 0.4), ('balance', 19.1), ('deposit', 24.7), ('transfer', 2.8000000000000003), ('withdrawal', 53.0)]