首页 > 编程语言 > 详细

python字典

时间:2019-12-12 21:15:40      阅读:57      评论:0      收藏:0      [点我收藏+]

字典即为放在花括号{}中一系列键值对的集合,值可以使数字、字符、集合等。

>>> employee_1 = {name: david, dept: ops, post: NOC, salary: 9999}
>>>
>>> type(employee_1)
<class dict>

访问字典中的数据

>>> print(employee_1)
{name: david, dept: ops, post: NOC, salary: 9999}
>>> 
>>> print(employee_1[name])
david
>>>
>>> print("Welcome our new colleague: " + employee_1[name] + ", " + "His post is: " + employee_1[post] + ".")
Welcome our new colleague: david, His post is: NOC.

 

 

python字典

原文:https://www.cnblogs.com/ilifeilong/p/12031227.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!