python数据结构
来源:互联网 发布:淘宝装修模板怎么使用 编辑:程序博客网 时间:2024/04/30 07:17
列表list用中括号[ ],元组用圆括号():
声明空元组 myempty=()
只含有一个元素的元组 :oneitem=(2, ) # 后面有逗号隔开,python才能区分逗号前的表达式
以上两者都用逗号隔开。列表是可变的,元组是不可变的。
字典的使用:
info={'chen':22, 'lin':21, 'future': 70}
for name,age in info.items():
print '%s is %d' % (name, age)
chen is 22
lin is 21
future is 70
>>>shoplist=['banana', 'pear', 'rice']
>>>mylist=shoplist #这两个变量名指向同一个存储空间
>>>del shoplist[0]
>>>print mylist
['pear', 'rice']
>>>shoplist.append('apple')
>>>mylist=shoplist[:] #取出shoplist中所有元素存入mylist中,则对两者的操作互不影响
>>> print mylist
['pear', 'rice', 'apple']
>>> del shoplist[1]
>>> print mylist
['pear', 'rice', 'apple']
0 0
- python数据结构
- python数据结构
- python 数据结构
- python 数据结构
- Python 数据结构
- Python数据结构
- python 数据结构
- python 数据结构
- python 数据结构
- python数据结构
- python-数据结构
- python数据结构
- python,数据结构
- Python-----数据结构
- python数据结构
- python 数据结构
- Python:数据结构
- python数据结构
- Android启动流程——Home Launcher
- Xcode的控制台调试命令
- ImageLoader
- 四种方案解决ScrollView嵌套ListView问题
- Git使用基本方法二(通过SSH加密传输连接git服务器)
- python数据结构
- CentOS 6.5的安装步骤与Unable to read package metadata问题的解决办法
- 按位运算符
- sql语句学习
- 安卓手机
- 第6周项目-我的数组类
- 网络状态检测方法分析
- 关于Xilinx芯片中Block RAM和Distributed RAM 的区别
- Eclipse背景设置