导航

 

判断对象是否是元组:

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

posted on 2019-08-23 10:04  一棵二叉树  阅读(256)  评论(0编辑  收藏  举报