Python练习-- list and tuple
2016-02-23 15:51
567 查看
#!/usr/bin/env python3 # -*- coding: utf-8 -*- classmates = ['Michael','Bob','Tracy'] print('classmates is:',classmates) print('len is',len(classmates)) print('classmates[0] is',classmates[0]) print('classmates[-1] is',classmates[-1]) classmates.append('Adam') print('classmates is:',classmates) classmates.insert(1,'Jack') print('classmates is:',classmates) print('pop:',classmates.pop()) print('classmates is:',classmates) print('pop:',classmates.pop(1)) print('classmates is:',classmates) classmates[1] = 'Sarah' print('classmates is:',classmates) L = [ ['Apple', 'Google', 'Microsoft'], ['Java', 'Python', 'Ruby', 'PHP'], ['Adam', 'Bart', 'Lisa'] ] print(L[0][0]) print(L[1][1]) print(L[2][2]) #This is tuple below: #变的是list,不变得是tuple中的指向 t = ('a', 'b', ['A', 'B']) t[2][0] = 'X' t[2][1] = 'Y' print(t)
相关文章推荐
- Python练习-- iterator
- Python练习-- condition
- [Leetcode]@python 92. Reverse Linked List II
- Python subprocess模块总结
- Python练习--character
- [解决] python WindowsError: [Error 3]
- Eclipse搭建Python开发环境+Python中文处理
- [Leetcode]@python 91. Decode Ways
- Python学习笔记_判断和循环
- Windows下Python开发环境搭建及 Python的HelloWorld示例
- python内置模块(四)
- python之文件编码转换
- 安装ipython import path error
- [备忘]Sublime Text 3 Python编辑环境搭建
- python升级
- python正则表达式基础篇
- Python 半开放socket
- python 解析html标签中的属性
- python-pexpect模块的使用(ssh服务器 自动登录批量执行scp)
- python代码风格指南:PEP8 中文