python列表
来源:互联网 发布:js 模块化框架 编辑:程序博客网 时间:2024/06/05 07:34
# -*- coding:UTF-8 -*-'''Created on 2015年10月25日@author: young'''list=[1,'abc']list.append(1)list.append(['lmn','xyz'] )list.extend([9,10])print listprint list.count('abc')list.reverse()print listprint list.index('abc' )print list.pop()print listlist.remove('abc')print listlist.sort()print listlist.insert( 1, ('a','b','c') ) #插入 元组print listprint '###for each###'for ele in list: print eleprint '###下标访问###'print list[1]#下标访问 print list[1:-1] #第二到倒数第一个print '元组'tt=( ('a',1) , ('b','b') ,(3,'c') )print ttfor ele in tt: print elefor (x,y) in tt: print x,',', y
打印如下
[1, 'abc', 1, ['lmn', 'xyz'], 9, 10]1[10, 9, ['lmn', 'xyz'], 1, 'abc', 1]41[10, 9, ['lmn', 'xyz'], 1, 'abc'][10, 9, ['lmn', 'xyz'], 1][1, 9, 10, ['lmn', 'xyz']][1, ('a', 'b', 'c'), 9, 10, ['lmn', 'xyz']]###for each###1('a', 'b', 'c')910['lmn', 'xyz']###下标访问###('a', 'b', 'c')[('a', 'b', 'c'), 9, 10]元组(('a', 1), ('b', 'b'), (3, 'c'))('a', 1)('b', 'b')(3, 'c')a , 1b , b3 , c
0 0
- Python 列表
- python 列表
- python--列表
- python 列表
- Python 列表
- Python 列表
- python 列表
- Python列表
- python列表
- Python列表
- Python列表
- python列表
- Python列表
- python 列表
- python列表
- python列表
- Python--列表
- Python-列表
- 第16章 SQL Mode及相关问题
- C++对参数直接赋值
- 第17章 Mysql分区
- Sizeof() and Strlen()的区别-20151026
- python类型转换
- python列表
- 检查点
- 第18章 SQL优化
- python输入
- Java 多线程----synchronized关键字详解
- Leetcode -- Trapping Rain Water
- 第19章 优化数据库对象
- C语言整理-9
- python数学计算