美文网首页python 学习
Python3 字典 items() 方法

Python3 字典 items() 方法

作者: 我觉得我脑子可能有点问题 | 来源:发表于2019-05-02 11:25 被阅读0次

语法

items()方法语法:

dict.items()

实例

以下实例展示了 items() 方法的使用方法:

实例

#!/usr/bin/python3 

dict = {'Name': 'Runoob', 'Age': 7}

print ("Value : %s" %  dict.items())

Value : dict_items([('Age', 7), ('Name', 'Runoob')])

遍历例子:

dict = {'Name': 'Runoob', 'Age': 7}for i,j in dict.items():    print(i, ":\t", j)

输出:

Name :  RunoobAge :    7

相关文章

网友评论

    本文标题:Python3 字典 items() 方法

    本文链接:https://www.haomeiwen.com/subject/docnnqtx.html