Introduction to Python programming of of 2 variable types
- 2020-04-02 13:46:52
- OfStack
In general, Python has a lot of variable/data types, but it doesn't need to be specified by the user because Some are generated from partial system functions . Others are automatically identified by the value of the variable , these data types are constant in Class types Define, so use when required The import types Such as:
import types
a = [1,2,3]
if type(a) is types.ListType:
print a
else:
print 'not list'
Python's specific variables/data types are as follows:
NoneType
None type
TypeType
Type object itself
BooleanType
Boolean type
IntType
Integer types
LongType
Long integer
FloatType
Floating point types
ComplexType
Complex type (such as 1.0j will not be defined if it is 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
A tuple type
ListType
List array type
DictType
Hash array type (dictionary array)
DictionaryType
Full name above
FunctionType
Function types
LambdaType
Alternate name for a function type
GeneratorType
Iterator object, generated by calling the function generator.
CodeType
For the type of the code object, for example, it is returned by compile().
ClassType
Object type
InstanceType
Object instance type
MethodType
Object method
UnboundMethodType
MethodType alternate name.
BuiltinFunctionType
Built-in function types, such as len() or sys.exit().
BuiltinMethodType
Alternate name for BuiltinFunction
ModuleType
Module type
FileType
Object of the file type opened by sys.stdout.
XRangeType
Xrange () returns the range selection object
SliceType
Slice () returns the object
EllipsisType
Omitted type.
TracebackType
Such as the object type returned by sys.exc_traceback
FrameType
A backtrace object such as TB. Tb_frame
BufferType
The type returned by the buffer() function