首页后端开发Pythonpython字典中items和iteritems的区别

python字典中items和iteritems的区别

时间2023-06-09 11:48:01发布访客分类Python浏览570
导读:python字典中items和iteritems的区别?items( 返回的是列表对象,而iteritems( 返回的是iterator对象。例如:print dic.items( #[('a', 'hello' , ('c', 'you...

python字典中items和iteritems的区别?

items()返回的是列表对象,而iteritems()返回的是iterator对象。例如:

print dic.items() #[('a', 'hello'), ('c', 'you'), ('b', 'how')]

print dic.iteritems() #

深究:iteritor是迭代器的意思,一次反悔一个数据项,知道没有为止

for i in dic.iteritems():

print i

结果:('a', 'hello')

('c', 'you')

('b', 'how')

声明:本文内容由网友自发贡献,本站不承担相应法律责任。对本内容有异议或投诉,请联系2913721942#qq.com核实处理,我们将尽快回复您,谢谢合作!


若转载请注明出处: python字典中items和iteritems的区别
本文地址: https://pptw.com/jishu/68241.html
怎么才能得到优质回答 pycharm中引号含义

游客 回复需填写必要信息