您的当前位置:首页正文

Python: Tuples, Sets, Fractions, Types

来源:九壹网

Tuples:

T = (1, 2, 3, 4)
len(T)

T + (5, 6)

T.index(4)
T.count(4)

#Tuples are immutable

 

Sets:

T = (1, 2, 3, 4)
len(T)

T + (5, 6)

T.index(4)
T.count(4)

#Tuples are immutable

 

 

Fractions:

from fractions import Fraction
f = Fraction(2, 3)
f+1
f + Fraction(1, 2)

 

 

Types:

L = [2, 3, 4]
type(L)	#<class 'list'> for 3.0 or higher

isinstance(L, list)	#True

转载于:https://www.cnblogs.com/kongs/archive/2011/10/28/2227987.html

因篇幅问题不能全部显示,请点此查看更多更全内容

Top