This article mainly introduces Python variable types. For more information, see Python variable/data types.
Some are generated based on some system functions,
Others are automatically identified based on the value of the variable., These data type constants are
Class typesDefinition.
Import typesFor example:
The Code is as follows:
Import types
A = [1, 2, 3]
If type (a) is types. ListType:
Print
Else:
Print 'not list'
Python variables/data types are as follows:
NoneType
None type
TypeType
Type object itself
BooleanType
Boolean Type
IntType
Integer type
LongType
Long Integer
FloatType
Floating Point Type
ComplexType
Plural type (for example, 1.0j will not be defined if not supported)
StringType
String type (e.g. 'Spam ').
UnicodeType
Unicode string (e.g. u 'spam' will not be defined if it is not supported)
TupleType
Tuples
ListType
Linked List array type
DictType
Hash array type (Dictionary array)
DictionaryType
The full name above
FunctionType
Function Type
LambdaType
Function Type backup name
GeneratorType
The iterator object generated by calling the function generator.
CodeType
The type of the Code object, for example, returned by compile.
ClassType
Object Type
InstanceType
Object instance type
MethodType
Object Method
UnboundMethodType
The backup name of MethodType.
BuiltinFunctionType
Built-in function types, such as len () or sys. exit ().
BuiltinMethodType
Alternate name of BuiltinFunction
ModuleType
Module type
FileType
Such as sys. stdout.
XRangeType
Range selection object returned by xrange ()
SliceType
Objects returned by slice ()
EllipsisType
Omitted type.
TracebackType
For example, the object type returned by sys. exc_traceback
FrameType
A backtracing object such as tb. tb_frame
BufferType
Type returned by the buffer () function