# -*- 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 list print list.count('abc') list.reverse() print list print list.index('abc' ) print list.pop() print list list.remove('abc') print list list.sort() print list list.insert( 1, ('a','b','c') ) #插入 元组 print list print '###for each###' for ele in list: print ele print '###下标访问###' print list[1]#下标访问 print list[1:-1] #第二到倒数第一个 print '元组' tt=( ('a',1) , ('b','b') ,(3,'c') ) print tt for ele in tt: print ele for (x,y) in tt: print x,',', y
[1, 'abc', 1, ['lmn', 'xyz'], 9, 10] 1 [10, 9, ['lmn', 'xyz'], 1, 'abc', 1] 4 1 [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') 9 10 ['lmn', 'xyz'] ###下标访问### ('a', 'b', 'c') [('a', 'b', 'c'), 9, 10] 元组 (('a', 1), ('b', 'b'), (3, 'c')) ('a', 1) ('b', 'b') (3, 'c') a , 1 b , b 3 , c