#coding=utf-8
animalslist=['fox','tiger','rabbit','snake']
print "I don't like these",len(animalslist),'animals...'
for items in animalslist:
print items,
print "\n操作后"
#对列表的操作,添加,删除,排序
animalslist.append('pig')
del animalslist[0]
animalslist.sort()
for i in range(0,len(animalslist)):
print animalslist[i],
I don't like these 4 animals... fox tiger rabbit snake
pig rabbit snake tiger
>>> zoo=('wolf','elephant','penguin')
>>> zoo.count('penguin')
1
>>> zoo.index('penguin')
2
>>> zoo.append('pig')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'tuple' object has no attribute 'append'
>>> del zoo[0]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'tuple' object doesn't support item deletion
#coding=utf-8
dict1={'zhang':'张家辉','wang':'王宝强','li':'李冰冰','zhao':'赵薇'}
#字典的操作,添加,删除,打印
dict1['huang']='黄家驹'
del dict1['zhao']
for firstname,name in dict1.items():
print firstname,name
li 李冰冰 wang 王宝强 huang 黄家驹 zhang 张家辉
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有