Python type(anyObj) 函数与 types 模块

来源:互联网 发布:淘宝上的水晶是真的吗 编辑:程序博客网 时间:2024/05/21 09:08

示例:

 

>>> import types

 

>>> type([])
<type 'list'>

>>> type([]) is types.ListType
True

 

>>> print type.__doc__
type(object) -> the object's type
type(name, bases, dict) -> a new type

 

>>> print types.__doc__
Define names for all type symbols known in the standard interpreter.

Types that are part of optional modules (e.g. array) are not listed.

 

>>> print ''.join("%s /n" % e for e in dir(types) if e[:2]!='__')
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

原创粉丝点击