如何避免字典键的重新排列?

时间:2019-09-23 22:31:10

标签: python python-3.x

我试图创建字典,但是键总是重新排列。我希望按适当的顺序安排钥匙。在python中有可能吗?

#!/bin/python

my_val = ["vel", "acc", "force"]

my_dict=dict()
for v in my_val:
  my_dict[v] = []

for l in my_val:
  print("l = ", l) 

print("dict re-arranges")
for key in my_dict:
  print("key = ", key)
l =  vel
l =  acc
l =  force
dict re-arranges
key =  force
key =  acc
key =  vel

0 个答案:

没有答案