Python standard library: built-in function type (object), pythonobject
Type (object)
Type (name, bases, dict)
This function is the type object of the returned object. If there is only one parameter object, the type object of the object is directly returned. If you only want to determine whether an object belongs to a class object, you can use the isinstance () function. This function does not need to return type objects for determination, because when there is an inheritance relationship, it does not return the type object of the base class.
When there are three parameters, name is the name of the class, bases is the tuples of the base class, And dict is the namespace variable defined in the class.
Example:
# Type () print (type ([]) print (type ([2]) print (type ({0: 'zero '}) class Foo: x = 1 y = 2 print (type ('foo', (object,), dict (x = 1 )))
The output is as follows:
<Class 'LIST'>
<Class 'LIST'>
<Class 'dict '>
<Class '_ main _. foo'>
Cai junsheng QQ: 9073204 Shenzhen