python 中list dict tuple的比较

本文对比了Python中list、dict、tuple的区别与应用,详细介绍了三者的特性、使用场景及实例演示。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

转自于 http://hi.baidu.com/kxw102/blog/item/6c36404789f1cc066a63e598.html

python的list,dict,tuple比较和应用

总结一下:

list是顺序的,可变的。
dictrionary是无顺序的,可变的
tuple是顺序的,不可变的。

 >>> a=((4,"abc"),(2,"efg"),(3,"ghi"))
>>> type(a)
<type 'tuple'>
>>> print list(a)[1]
(2, 'efg')
>>> print dict(a)[1]
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
KeyError: 1
>>> print dict(a)[2]
efg

http://hi.baidu.com/nirenyang/blog/item/d145bf50401f217884352411.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值