分类: LINUX
2008-06-30 15:00:49
__add__ x.__add__(y) <==> x+y
__class__ tuple() -> an empty tuple tuple(sequence) -> tuple initialized from sequence's items If the argument is a tuple, the return value is the same object.
__contains__ x.__contains__(y) <==> y in x
__delattr__ x.__delattr__('name') <==> del x.name
__eq__ x.__eq__(y) <==> x==y
__ge__ x.__ge__(y) <==> x>=y
__getattribute__ x.__getattribute__('name') <==> x.name
__getitem__ x.__getitem__(y) <==> x[y]
__getnewargs__ None
__getslice__ x.__getslice__(i, j) <==> x[i:j] Use of negative indices is not supported.
__gt__ x.__gt__(y) <==> x>y
__hash__ x.__hash__() <==> hash(x)
__init__ x.__init__(...) initializes x; see x.__class__.__doc__ for signature
__iter__ x.__iter__() <==> iter(x)
__le__ x.__le__(y) <==> x<=y
__len__ x.__len__() <==> len(x)
__lt__ x.__lt__(y) <==> x
__ne__ x.__ne__(y) <==> x!=y
__new__ T.__new__(S, ...) -> a new object with type S, a subtype of T
__reduce__ helper for pickle
__reduce_ex__ helper for pickle
__repr__ x.__repr__() <==> repr(x)
__rmul__ x.__rmul__(n) <==> n*x
__setattr__ x.__setattr__('name', value) <==> x.name = value
__str__ x.__str__() <==> str(x)
|
不能向 tuple 增加、删除、索引元素,但可以查找,如用in
那么使用 tuple 有什么好处呢:
Tuple 可以转换成 list, 反之亦然。内置的 tuple 函数接收一个 list, 并返回一个有着相同元素的 tuple。而 list 函数接收一个 tuple 返回一个 list。从效果上看, tuple 冻结一个 list, 而 list 解冻一个 tuple。 |