r****t 发帖数: 10904 | 1 http://blog.labix.org/2008/06/27/watch-out-for-listdictkeys-in-python-3
Watch out for list(dict.keys()) in Python 3
Gustavo Niemeyer
As everyone is probably aware by now, in Python 3 dict.keys(), dict.values()
and dict.items() will all return iterable views instead of lists. The
standard way being suggested to overcome the difference, when the original
behavior was actually intended, is to simply use list(dict.keys()). This
should be usually fine, but not in all cases.
One of the reasons why som |
|