当我运行这个简单的程序时:
example: {'left', 'right', 'up', 'down'}
new_dict = dict(enumerate(example))
print(new_dict)
每次运行都会产生不同的(索引、值)对。例如:
MacBook-Air:Desktop mymac$ python3 example.py
{0: 'right', 1: 'down', 2: 'left', 3: 'up'}
MacBook-Air:Desktop mymac$ python3 example.py
{0: 'left', 1: 'up', 2: 'down', 3: 'right'}
MacBook-Air:Desktop mymac$ python3 example.py
{0: 'down', 1: 'left', 2: 'right', 3: 'up'}
为什么?你知道吗
从文档https://docs.python.org/3/reference/datamodel.html#object.hash
相关问题 更多 >
编程相关推荐