posts - 27,  comments - 3,  trackbacks - 0
Example 3.15 Defining a tuple
1、tuple没有任何方法
2、tuple和list可以相互转化
4、
Common tuple literals and operations

Operation

Interpretation

( )

An empty tuple

t1 = (0,)

A one-item tuple (not an expression)

t2 = (0, 'Ni', 1.2, 3)

A four-item tuple

t2 = 0, 'Ni', 1.2, 3

Another four-item tuple (same as prior line)

t3 = ('abc', ('def', 'ghi'))

Nested tuples

t1[i]t3[i][j]t1[i:j]len(t1)

Index, slice, length

t1 + t2t2 * 3

Concatenate, repeat

for x in t23 in t2

Iteration, members


tuple这些操作和list非常之象。。


Jafe 2007-08-28 21:11 发表评论
posted on 2007-08-28 21:11 Jeff Lee 阅读(167) 评论(0)  编辑  收藏 所属分类: python

只有注册用户登录后才能发表评论。


网站导航:
 

<2007年8月>
2930311234
567891011
12131415161718
19202122232425
2627282930311
2345678

常用链接

留言簿(1)

随笔分类

随笔档案

搜索

  •  

最新评论

阅读排行榜

评论排行榜