新郑IT教育网


python站群系统

adc110在线观看-成都学python学校:Python中dir()、help()的使用

Python中dir()、help()的使用

Python中的内置方法有很多,今天简单的说一下dir和helo的用法。当我们需要使用某些函数或者模块,对于内部的有些函数不清楚时,可以通过这两个函数进行查看具体的用法。

dir():用于查看对象内的属性以及方法。

help():用于查看属性和方法的详细说明

dir

查看adc110在线观看这个对象内的属性和方法

>>>dir(adc110在线观看)['__add__','__class__','__contains__', '__delattr__','__dir__','__doc__','__eq__','__format__','__ge__', '__getattribute__','__getitem__','__getnewargs__','__gt__','__hash__', '__init__','__init_subclass__','__iter__','__le__','__len__','__lt__', '__mod__','__mul__','__ne__','__new__','__reduce__','__reduce_ex__', '__repr__','__rmod__','__rmul__','__setattr__','__sizeof__','__adc110在线观看__', '__subclasshook__','capitalize','casefold','center','count','encode', 'endswith','expandtabs','find','format','format_map','index','isalnum', 'isalpha','isascii','isdecimal','isdigit','isidentifier','islower', 'isnumeric','isprintable','isspace','istitle','isupper','join','ljust', 'lower','ladc110在线观看ip','maketrans','partition','replace','rfind','rindex', 'rjust','rpartition','rsplit','radc110在线观看ip','split','splitlines','startswith', 'adc110在线观看ip','swapcase','title','translate','upper','zfill']>>>

当dir不带参数执行时,返回当前范围内的变量、方法和属性列表>>>dir()['__annotations__', '__builtins__','__doc__','__loader__','__name__','__pack**e__', '__spec__']

help

查看help属性和方法的详细说明,可通过Enter键加载更多。

>>>help('adc110在线观看')

Helponclassadc110在线观看inmodulebuiltins:

classadc110在线观看(object)

|adc110在线观看(object='')->adc110在线观看

|adc110在线观看(bytes_or_buffer[,encoding[,errors]])->adc110在线观看

||Createanewadc110在线观看ingobjectfromthegivenobject.Ifencodingor

|errorsisspecified,thentheobjectmustexposeadatabuffer

|thatwillbedecodedusingthegivenencodinganderrorhandler.

|Otherwise,returnstheresultofobject.__adc110在线观看__()(ifdefined)|or repr(object).

|encodingdefaultstosys.getdefaultencoding().

|errorsdefaultsto'adc110在线观看ict'.

||Methodsdefinedhere:

||__add__(self,value,/)

|Returnself+value.

||__contains__(self,key,/)

|Returnkeyinself.

||__eq__(self,value,/)

|Returnself==value.

||__format__(self,format_spec,/)

|Returnaformattedversionoftheadc110在线观看ingasdescribedbyformat_spec.

||__ge__(self,value,/)

|Returnself>=value.||__getattribute__(self,name,/)

|Returngetattr(self,name).

||__getitem__(self,key,/)

|Returnself[key].||__getnewargs__(...)||__gt__(self,value,/)

|Returnself>value.||__hash__(self,/)

|Returnhash(self).||__iter__(self,/)

|Implementiter(self).||__le__(self,value,/)

|Returnself<=value.||__len__(self,/)

|Returnlen(self).||__lt__(self,value,/)

|Returnself

|Returnself%value.

--More--

>>>

当不带参数是help()则进入内置的帮助系统,可以在帮助系统内输入对象名进行查看。

>>>help()#进入帮助系统

WelcometoPython3.7'shelputility!

IfthisisyourfirsttimeusingPython,youshoulddefinitelycheck out

thetutorialontheInternetathttps://docs.adc110在线观看.org/3.7/tutorial/.

Enterthenameofanymodule,keyword,ortopictogethelponwriting

PythonprogramsandusingPythonmodules.Toquitthishelputilityand

returntotheinterpreter,justtype"quit".

Togetalistofavailablemodules,keywords,symbols,ortopics,type

"modules","keywords","symbols",or"topics".Eachmodulealsocomes

withaone-linesummaryofwhatitdoes;tolistthemoduleswhosename

orsummarycontain**ivenadc110在线观看ingsuchas"spam",type"modulesspam".

help>adc110在线观看#查看adc110在线观看的详细说明

Helponclassadc110在线观看inmodulebuiltins:

classadc110在线观看(object)

|adc110在线观看(object='')->adc110在线观看

|adc110在线观看(bytes_or_buffer[,encoding[,errors]])->adc110在线观看

||Createanewadc110在线观看ingobjectfromthegivenobject.Ifencodingor

|errorsisspecified,thentheobjectmustexposeadatabuffer

|thatwillbedecodedusingthegivenencodinganderrorhandler.

|Otherwise,returnstheresultofobject.__adc110在线观看__()(ifdef

(责任编辑:范老师)