Python对象
1、标准类型
整形、布尔型、长整形、浮点型、复数型、字符串、列表、元组、字典
2、Type()获取特定对象的类型信息
>>> type(42)
<class 'int'>
>>> type(type(42))
<class 'type'>
3、切片对象
>>> foostr="abcde"
>>> foostr[::-1]
'edcba'
>>> foostr[::-2]
'eca'
>>> foolist=[123,"xba",342.23,"abc"]
>>> foolist[::-1]
['abc', 342.23, 'xba', 123]
4、对象值的比较
>>> 2==2
True
>>> 2.46 <= 8.33
True
>>> "abc" == "xyz"
False
>>> "abc" >= "xyz"
False
>>> "abc" < "xyz"
True
>>> [3,"abc"] == ["abc",3]
False
>>> [3,"abc"] == [3,"abc"]
True
>>> 3<4<7
True
>>> 4>3==3
True
>>> 4<3<5 != 2<7
False
>>> foo1=foo2=4.3
>>> foo2
4.3
>>> a=[5,"hat",-9.3]
>>> b=a
>>> a is b
True
>>> a is not b
False
>>> b=2.5e-5
>>> b
2.5e-05
>>> a
[5, 'hat', -9.3]
>>> a is b
False
>>> a is not b
True
>>> a=1
>>> id(1)
1349479440
>>> b=1
>>> id(b)
1349479440
>>> c=1.0
>>> id(c)
109516034576
>>> d=1.0
>>> id(d)
109516034552
5、布尔类型
操作优先级从高到低:not、and、or
>>> x,y= 3.1415926536,-1024
>>> x<5.0
True
>>> not(x<5.0)
False
>>> (x<5.0)and(y>2.718281828)
False
>>> not(x is y)
True
6、type()
type()接受一个对象作为参数,并返回它的类型,它的返回值是一个类型对象。
>>> type(object)
<class 'type'>
>>>