功能:返回帮助信息
>>>help(help)
Help on _Helper in module _sitebuiltins object:class_Helper(builtins.object)| Define the builtin 'help'.|| This is a wrapper around pydoc.help that provides a helpful message
| when 'help'is typed at the Python interactive prompt.|| Calling help() at the Python prompt starts an interactive help session.| Calling help(thing) prints helpfor the python object'thing'.|| Methods defined here:|| __call__(self,*args,**kwds)| Call self as a function.|| __repr__(self)| Return repr(self).||----------------------------------------------------------------------| Data descriptors defined here:|| __dict__
| dictionary for instance variables (if defined)|| __weakref__
|list of weak references to the object(if defined)>>>
举例:
>>>help(dir)
Help on built-in function dirin module builtins:dir(...)dir([object])->list of strings
If called without an argument,return the names in the current scope.
Else,return an alphabetized list of names comprising (some of) the attributes
of the given object,and of attributes reachable from it.
If the object supplies a method named __dir__, it will be used; otherwise
the default dir() logic is used and returns:for a module object: the module's attributes.for a classobject: its attributes,and recursively the attributes
of its bases.forany other object: its attributes, its class's attributes,and
recursively the attributes of its class's base classes.>>>
2.2、dir
功能:返回对象属性和方法,包含递归的属性和方法。
>>>help(dir)
Help on built-in function dirin module builtins:dir(...)dir([object])->list of strings
If called without an argument,return the names in the current scope.
Else,return an alphabetized list of names comprising (some of) the attributes
of the given object,and of attributes reachable from it.
If the object supplies a method named __dir__, it will be used; otherwise
the default dir() logic is used and returns:for a module object: the module's attributes.for a classobject: its attributes,and recursively the attributes
of its bases.forany other object: its attributes, its class's attributes,and
recursively the attributes of its class's base classes.>>>
举例:
##查看列表的属性和方法>>>dir(list)['__add__','__class__','__contains__','__delattr__','__delitem__','__dir__','__doc__','__eq__','__format__','__ge__','__getattribute__','__getitem__','__gt__','__hash__','__iadd__','__imul__','__init__','__init_subclass__','__iter__','__le__','__len__','__lt__','__mul__','__ne__','__new__','__reduce__','__reduce_ex__','__repr__','__reversed__','__rmul__','__setattr__','__setitem__','__sizeof__','__str__','__subclasshook__','append','clear','copy','count','extend','index','insert','pop','remove','reverse','sort']>>>>>>import sys
>>>##查看sys模块的属性和方法>>>dir(sys)['__breakpointhook__','__displayhook__','__doc__','__excepthook__','__interactivehook__','__loader__','__name__','__package__','__spec__','__stderr__','__stdin__','__stdout__','__unraisablehook__','_base_executable','_clear_type_cache','_current_frames','_debugmallocstats','_enablelegacywindowsfsencoding','_framework','_getframe','_git','_home','_xoptions','addaudithook','api_version','argv','audit','base_exec_prefix','base_prefix','breakpointhook','builtin_module_names','byteorder','call_tracing','callstats','copyright','displayhook','dllhandle','dont_write_bytecode','exc_info','excepthook','exec_prefix','executable','exit','flags','float_info','float_repr_style','get_asyncgen_hooks','get_coroutine_origin_tracking_depth','getallocatedblocks','getcheckinterval','getdefaultencoding','getfilesystemencodeerrors','getfilesystemencoding','getprofile','getrecursionlimit','getrefcount','getsizeof','getswitchinterval','gettrace','getwindowsversion','hash_info','hexversion','implementation','int_info','intern','is_finalizing','last_traceback','last_type','last_value','maxsize','maxunicode','meta_path','modules','path','path_hooks','path_importer_cache','platform','prefix','pycache_prefix','set_asyncgen_hooks','set_coroutine_origin_tracking_depth','setcheckinterval','setprofile','setrecursionlimit','setswitchinterval','settrace','stderr','stdin','stdout','thread_info','unraisablehook','version','version_info','warnoptions','winver']>>>
2.3、id
功能:返回对象的标识(内存地址)
>>>help(id)
Help on built-in function idin module builtins:id(obj,/)
Return the identity of an object.
This is guaranteed to be unique among simultaneously existing objects.(CPython uses the object's memory address.)>>>
举例:
>>>id(3)8791345338080>>>id('abc')31174064>>>>>>id([1,2,3])47510848>>>
2.4、ord
功能:返回单字符字符串的Unicode代码点。
>>>help(ord)
Help on built-in function ordin module builtins:ord(c,/)
Return the Unicode code point for a one-character string.
举例:
>>>ord('a')97>>>>>>ord('b')98>>>>>>ord('A')65>>>>>>ord('每')27599>>>
2.5、 type
功能:查询对象类型
>>>help(type)
Help on classtypein module builtins:classtype(object)|type(object_or_name, bases,dict)|type(object)-> the object's type|type(name, bases,dict)-> a new type|
举例:
>>>type(1)<class'int'>>>>type(1.0)<class'float'>>>>type('abc')<class'str'>>>>