3.4.6 items和iteritems

  1. 说明:items以列表方式返回字典中的键值对,iteritems以迭代器对象 返回键值对儿(Python3中不再支持);
  2. 例子:
     1:  >>> x
    
     2:  {'name': 'Bill'}
    
     3:  >>> x.items()
    
     4:  dict_items([('name', 'Bill')])
    
     5:  
    
     6:  #python3中不再包含iteritems
    
     7:  >>> x.iteritems()
    
     8:  Traceback (most recent call last):
    
     9:    File "<pyshell#66>", line 1, in <module>
    
    10:      x.iteritems()
    
    11:  AttributeError: 'dict' object has no attribute 'iteritems'
    
    12:  

相关文章:

  • 2021-09-11
  • 2021-06-22
  • 2022-12-23
  • 1970-01-01
  • 2021-09-12
  • 2022-12-23
  • 2021-08-06
猜你喜欢
  • 2022-12-23
  • 2021-09-17
  • 2022-12-23
  • 2022-12-23
  • 2021-08-19
  • 2021-08-06
  • 2021-11-03
相关资源
相似解决方案