标签:des style blog http io color ar 使用 sp
Python 对象
python中一切皆为对象,所谓对象:我自己就是一个对象,我玩的电脑就是对象,坐着的椅子就是对象,家里养的小狗也是一个对象。。。。。。
我们通过描述属性(特征)和行为来描述一个对象的。比如家里的小狗,它的颜色,大小,年龄,体重等是它的属性或特征。它会汪汪叫,会摇尾巴等是它的行为。
我们在描述一个真实对象(物体)时包括两个方面:
它可以做什么(行为)
它是什么样的(属性或特征)。
在python中,一个对象的特征也称为属性(attribute)。它所具有的行为也称为方法(method)
结论:对象=属性+方法
对象三特性:
>>> b = 1 >>> type(b) <type ‘int‘> >>> type(int) <type ‘type‘> >>> type(type) <type ‘type‘>
b的类型是int型, int的类型是‘类型’,type的类型还是类型。
3. 值:对象表示的数据项
对象属性
属性:用来描述具体某个对象的特征的是属性,是静态的。比如:姚明身高2.6米多;小白的毛发是棕色的;二郎神额头上有只眼睛;
标准类型
数据类型 |
存储模型 |
更新模型 |
访问模型 |
数字 |
Scalar原子类型 |
不可更改 |
直接访问 |
字符串 |
Scalar原子类型 |
不可更改 |
顺序访问 |
列表 |
Container容器 |
可更改 |
顺序访问 |
元组 |
Container容器 |
不可更改 |
顺序访问 |
字典 |
Container容器 |
可更改 |
映射访问 |
其他类型:
内部类型(暂时初步了解)
内建函数
Built-in Functions | ||||
参考官网:Built-in Functions
标准类型运算符和内建函数
Operator/Function |
Description |
Result |
String |
||
‘‘ |
String representation |
st |
cmp(obj1, obj2) |
Compares two objects |
in |
repr(obj) |
String representation |
st |
str(obj) |
String representation |
st |
type(obj) |
Determines object type |
typ |
Value comparisons |
||
< |
Less than |
boo |
> |
Greater than |
boo |
<= |
Less than or equal to |
boo |
>= |
Greater than or equal to |
boo |
== |
Equal to |
boo |
!= |
Not equal to |
boo |
<> |
Not equal to |
boo |
Object comparisons |
||
is |
The same as |
boo |
is not |
Not the same as |
boo |
Boolean operators |
||
not |
Logical negation |
boo |
and |
Logical conjunction |
boo |
or |
Logical disjunction |
boo |
工厂函数
虽然看上去有点象函数, 实质上他们是类。当你调用它们时, 实际上是生成了该类型的一个实例。
int()、long()、float()、complex()、str()、unicode()、basestring()、list()、tuple()、type()
dict()、bool()、set()、frozenset()、object()、classmethod()、staticmethod()、super()、property()、file()
标签:des style blog http io color ar 使用 sp
原文地址:http://www.cnblogs.com/sunnyjiangjie/p/4079923.html