Everfighting
5/18/2017 - 2:39 PM

如何让字典保持有序

如何让字典保持有序

from time import time
from random import ranint
from collections import OrderedDict

d = OrderedDict()
players = list('ABCDEFGH')
start = time()

for i in range(8):
  input()
  players.pop(randint(0,7-i))
  end = time()
  print(i+1,p,end-start)
  d[p] = (i+1,end-start)
  
print ('-'*20)

for k in d:
  print(k,d[k])