[ Web Proxy ]
URL:
Viewing: https://raw.githubusercontent.com/lqlstudio/netkiller.github.io/master/python/../python/type.html [Back]  [Original]

4Home | | | | Search | ITEYE | OSChina | Facebook | Linkedin | | Email

4

4.1. type
4.2. String
4.2.1. String function
4.2.1.1. str.find()
4.2.1.2. str.find()
4.2.2. Convert str to bytes in python
4.2.3. String format
4.3. Array
4.3.1. split / join
4.4. Datetime
4.4.1. datetime
4.5. bytes
4.5.1. BOM
4.5.2. replace
4.5.3. pack/unpack

4.1.type

http://docs.python.org/library/types.html

		
>>> type( [] ) == list
True
>>> type( {} ) == dict
True
>>> type( "" ) == str
True
>>> type( 0 ) == int
True
>>> class Test1 ( object ):
    pass
>>> class Test2 ( Test1 ):
    pass
>>> a = Test1()
>>> b = Test2()
>>> type( a ) == Test1
True
>>> type( b ) == Test2
True
>>> type( b ) == Test1
False
>>> isinstance( b, Test1 )
True
>>> isinstance( b, Test2 )
True
>>> isinstance( a, Test1 )
True
>>> isinstance( a, Test2 )
False
>>> isinstance( [], list )
True
>>> isinstance( {}, dict )
True
		
		
		
>>> a = []
>>> type(a)
<type 'list'>
>>> f = ()
>>> type(f)
<type 'tuple'>
		
		
comments powered by Disqus

Web Proxy Viewer  |  New URL  |  Original Page