仅适用于Python 2.x(感谢Alex):
yourdict = {}
# ...
items = yourdict.items()
有关详细信息,请参见http://docs.python.org/library/stdtypes.html#dict.items。
仅适用于Python 3.x:
yourdict = {}
# ...
items = list(yourdict.items())
Python中的dict中的元组列表
仅适用于Python 2.x(感谢Alex):
yourdict = {}
# ...
items = yourdict.items()
有关详细信息,请参见http://docs.python.org/library/stdtypes.html#dict.items。
仅适用于Python 3.x:
yourdict = {}
# ...
items = list(yourdict.items())