python 中所有原始类型

判断对象是否是元组:

isinstance(val, types.TupleType)

types.TupleType == type(val)

判断是否是函数:

isinstance(func, types.FunctionType)

 

需要引入types模板,获取数据类型:

inport types

types取值:

  BooleanType
  BufferType
  BuiltinFunctionType
  BuiltinMethodType
  ClassType
  CodeType
  ComplexType
  DictProxyType
  DictType
  DictionaryType
  EllipsisType
  FileType
  FloatType
  FrameType
  FunctionType
  GeneratorType
  GetSetDescriptorType
  InstanceType
  IntType
  LambdaType
  ListType
  LongType
  MemberDescriptorType
  MethodType
  ModuleType
  NoneType
  NotImplementedType
  ObjectType
  SliceType
  StringType
  StringTypes
  TracebackType
  TupleType
  TypeType
  UnboundMethodType
  UnicodeType
  XRangeType

原文地址:https://www.cnblogs.com/sen-2017/p/11398332.html