做http://stardict.sourceforge.net/Dictionaries.php下载preserve迭代顺序,如果他们不被修改?不被、顺序、迭代、sourceforge

由网友(旧情劫)分享简介:如果我有Python中的字典,我通过它遍历一次,然后再后来,是保证是$ P $迭代顺序pserved因为我没有插入,删除或更新中的所有项目字典? (不过,我可能会做的查找窗口)。If I have a dictionary in Python, and I iterate through it once, and t...

如果我有Python中的字典,我通过它遍历一次,然后再后来,是保证是$ P $迭代顺序pserved因为我没有插入,删除或更新中的所有项目字典? (不过,我可能会做的查找窗口)。

If I have a dictionary in Python, and I iterate through it once, and then again later, is the iteration order guaranteed to be preserved given that I didn't insert, delete, or update any items in the dictionary? (But I might have done look-ups).

推荐答案

下面是 dict.items()的文档说:

dict.items()返回(键,值)对字典的列表的副本。

dict.items() return a copy of the dictionary’s list of (key, value) pairs.

如果产品(),键(),值(),iteritems(),出iterkeys(),和itervalues​​()称为中间没有修改到词典中,列出了将直接对应

If items(), keys(), values(), iteritems(), iterkeys(), and itervalues() are called with no intervening modifications to the dictionary, the lists will directly correspond.

我认为这是合理的假设,项目顺序不会改变,如果你要做的就是迭代。

I think it's reasonable to assume that item ordering won't change if all you do is iteration.

阅读全文

相关推荐

最新文章