Python中使用items()方法返回字典元素对的教程,pythonitems
Python中使用items()方法返回字典元素对的教程,pythonitems
items()方法返回字典的(键,值)元组对的列表
语法
以下是items()方法的语法:
dict.items()
参数
- NA
返回值
此方法返回元组对的列表。
例子
下面的例子显示了items()方法的使用。
#!/usr/bin/python dict = {'Name': 'Zara', 'Age': 7} print "Value : %s" % dict.items()
当我们运行上面的程序,它会产生以下结果:
Value : [('Age', 7), ('Name', 'Zara')]
相关内容
- 在Python中用keys()方法返回字典键的教程,pythonkeys
- 在Python中操作字典之setdefault()方法的使用,pythonsetdef
- python计算时间差的方法,python计算时间差
- 在Python中使用swapCase()方法转换大小写的教程,pythonsw
- python网络编程之数据传输UDP实例分析,pythonudp实例分析
- python中enumerate函数用法实例分析,pythonenumerate
- Python中title()方法的使用简介,pythontitle
- python网络编程之文件下载实例分析,
- Python中zfill()方法的使用教程,pythonzfill
- 在Python中处理字符串之isdecimal()方法的使用,pythonisde
评论关闭