我有这句话:
def Ciudad(prob):
numero = random.random()
ciudad = prob.keys()[0]
for i in prob.keys():
if(numero > prob[i]):
if(prob[i] > prob[ciudad]):
ciudad = i
else:
if(prob[i] > prob[ciudad]):
ciudad = i
return ciudad
但是当我调用它时,会弹出这个错误:
TypeError: 'dict_keys' object does not support indexing
是版本问题吗?我正在使用 Python 3.3.2