Type (object)
Type (name, bases, Dict)
This function is the type object that returns the object. When there is only one argument to object, the type object is returned directly. If you just want to determine whether an object belongs to an object of a class, you can use the isinstance () function, which does not require the return type object of this function, because it does not return the type object of the base class when there is an inheritance relationship.
When there are three parameters, name is the name of the class;bases is the tuple of the base class;dict is a namespace variable defined within 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 resulting output is as follows:
<class ' list ' >
<class ' list ' >
<class ' Dict ' >
<class ' __main__. Foo ' >
Cai Junsheng qq:9073204 Shenzhen
Python standard library: Built-in function type (object)