当前位置: 首页 > news >正文

版纳网站建设优速网站建设优化seo

版纳网站建设,优速网站建设优化seo,网站头部导航样式,宁波网站建设外包在使用 dir() 函数和 __all__ 变量的基础上,虽然我们能知晓指定模块(或包)中所有可用的成员(变量、函数和类),比如:import string print(string.__all__)程序执行结果为:[ascii_lett…

在使用 dir() 函数和 __all__ 变量的基础上,虽然我们能知晓指定模块(或包)中所有可用的成员(变量、函数和类),比如:

import string
print(string.__all__)

程序执行结果为:

['ascii_letters', 'ascii_lowercase', 'ascii_uppercase', 'capwords', 'digits', 'hexdigits', 'octdigits', 'printable', 'punctuation', 'whitespace', 'Formatter', 'Template']

但对于以上的输出结果,对于不熟悉 string 模块的用户,还是不清楚这些名称分别表示的是什么意思,更不清楚各个成员有什么功能。

针对这种情况,我们可以使用 help() 函数来获取指定成员(甚至是该模块)的帮助信息。以前面章节创建的 my_package 包为例,该包中包含 __init__.py 、module1.py 和 module2.py 这 3 个模块,它们各自包含的内容分别如下所示:

#***__init__.py 文件中的内容***
from my_package.module1 import*
from my_package.module2 import*#***module1.py 中的内容***
#module1.py模块文件
defdisplay(arc):'''直接输出指定的参数'''
print(arc)#***module2.py中的内容***
#module2.py 模块文件
class CLanguage:'''CLanguage是一个类,其包含:display() 方法'''
defdisplay(self):
print("http://csdn.net/python/")

现在,我们先借助 dir() 函数,查看 my_package 包中有多少可供我们调用的成员:

import my_package
print([e for e indir(my_package)ifnot e.startswith('_')])

程序输出结果为:

['CLanguage', 'display', 'module1', 'module2']

通过此输出结果可以得知,在 my_package 包中,有以上 4 个成员可供我们使用。接下来,我们使用 help() 函数来查看这些成员的具体含义(以 module1 为例):

import my_package
help(my_package.module1)

输出结果为:

Help on module my_package.module1 in my_package:

NAME
my_package.module1 - #module1.py模块文件

FUNCTIONS
display(arc)
直接输出指定的参数

FILE
c:\users\mengma\desktop\my_package\module1.py

通过输出结果可以得知,module1 实际上是一个模块文件,其包含 display() 函数,该函数的功能是直接输出指定的 arc 参数。同时,还显示出了该模块具体的存储位置。

当然,有兴趣的读者还可以尝试运行如下几段代码:

#输出 module2 成员的具体信息
help(my_package.module2)
#输出 display 成员的具体信息
help(my_package.module1.display)
#输出 CLanguage 成员的具体信息
help(my_package.module2.CLanguage)

值得一提的是,之所以我们可以使用 help() 函数查看具体成员的信息,是因为该成员本身就包含表示自身身份的说明文档(本质是字符串,位于该成员内部开头的位置)。前面讲过,无论是函数还是类,都可以使用 __doc__ 属性获取它们的说明文档,模块也不例外。

以 my_package 包 module1 模块中的 display() 函数为例,我们尝试用 __doc__ 变量获取其说明文档:程序执行结果为:

直接输出指定的参数

其实,help() 函数底层也是借助 __doc__ 属性实现的。

那么,如果使用 help() 函数或者 __doc__ 属性,仍然无法满足我们的需求,还可以使用以下 2 种方法:

  1. 调用 __file__ 属性,查看该模块或者包文件的具体存储位置,直接查看其源代码(后续章节或详细介绍);

  1. 对于非自定义的模块或者包,可以查阅 Python 库的参考文档 https://docs.python.org/3/library/index.html。


文章转载自:
http://dinncoteacher.tqpr.cn
http://dinncoogival.tqpr.cn
http://dinncooratrix.tqpr.cn
http://dinncoprestissimo.tqpr.cn
http://dinncohaffir.tqpr.cn
http://dinncohereunder.tqpr.cn
http://dinncoreproduceable.tqpr.cn
http://dinncogrinding.tqpr.cn
http://dinncowigless.tqpr.cn
http://dinncocephalopod.tqpr.cn
http://dinncoalmug.tqpr.cn
http://dinncomiscall.tqpr.cn
http://dinncoexpositorial.tqpr.cn
http://dinnconevertheless.tqpr.cn
http://dinncoepochmaking.tqpr.cn
http://dinncosalivator.tqpr.cn
http://dinncothioguanine.tqpr.cn
http://dinncotrinocular.tqpr.cn
http://dinncoadrienne.tqpr.cn
http://dinncoreanimate.tqpr.cn
http://dinncolactonization.tqpr.cn
http://dinncocrumblings.tqpr.cn
http://dinncosquirarch.tqpr.cn
http://dinncosimplex.tqpr.cn
http://dinncosuccedaneum.tqpr.cn
http://dinncocliquey.tqpr.cn
http://dinncouneducated.tqpr.cn
http://dinncoteacherless.tqpr.cn
http://dinncodunaj.tqpr.cn
http://dinncooxycalcium.tqpr.cn
http://dinncosamekh.tqpr.cn
http://dinnconis.tqpr.cn
http://dinncomultibarrel.tqpr.cn
http://dinncoagrobiology.tqpr.cn
http://dinncononcontentious.tqpr.cn
http://dinncoengagement.tqpr.cn
http://dinncolockdown.tqpr.cn
http://dinncofjeld.tqpr.cn
http://dinncorq.tqpr.cn
http://dinncoleary.tqpr.cn
http://dinncoconsternation.tqpr.cn
http://dinncopessary.tqpr.cn
http://dinncospadger.tqpr.cn
http://dinncotickbird.tqpr.cn
http://dinncostroke.tqpr.cn
http://dinncodynamicfocus.tqpr.cn
http://dinncochasid.tqpr.cn
http://dinncovop.tqpr.cn
http://dinncolandrace.tqpr.cn
http://dinncosceptical.tqpr.cn
http://dinncogremlin.tqpr.cn
http://dinncougsome.tqpr.cn
http://dinncobestiality.tqpr.cn
http://dinncocrossed.tqpr.cn
http://dinncopantagruelist.tqpr.cn
http://dinncocemically.tqpr.cn
http://dinncosabre.tqpr.cn
http://dinncoimprecatory.tqpr.cn
http://dinncolunger.tqpr.cn
http://dinncomispronunciation.tqpr.cn
http://dinncopolarizability.tqpr.cn
http://dinncocockade.tqpr.cn
http://dinncomorganite.tqpr.cn
http://dinncoapulia.tqpr.cn
http://dinncoimmission.tqpr.cn
http://dinncoimmediately.tqpr.cn
http://dinncohyoscyamin.tqpr.cn
http://dinncomajesty.tqpr.cn
http://dinncochainsaw.tqpr.cn
http://dinncosonnet.tqpr.cn
http://dinncostand.tqpr.cn
http://dinncoembryocardia.tqpr.cn
http://dinncosurly.tqpr.cn
http://dinncowashtub.tqpr.cn
http://dinncophytoalexin.tqpr.cn
http://dinncosea.tqpr.cn
http://dinncodisjointed.tqpr.cn
http://dinnconaida.tqpr.cn
http://dinncoordinate.tqpr.cn
http://dinncoinappellability.tqpr.cn
http://dinncotubby.tqpr.cn
http://dinncobiostatics.tqpr.cn
http://dinncolidless.tqpr.cn
http://dinncopapalize.tqpr.cn
http://dinncocoocoo.tqpr.cn
http://dinncomicrosystem.tqpr.cn
http://dinncosudsy.tqpr.cn
http://dinncoprecoital.tqpr.cn
http://dinncoslovenian.tqpr.cn
http://dinncoreconnoitre.tqpr.cn
http://dinncomoskva.tqpr.cn
http://dinncoretouch.tqpr.cn
http://dinncodepredatory.tqpr.cn
http://dinncoprintable.tqpr.cn
http://dinncopermanganate.tqpr.cn
http://dinncosansculottism.tqpr.cn
http://dinncocrossbeding.tqpr.cn
http://dinncounschooled.tqpr.cn
http://dinncodudheen.tqpr.cn
http://dinncoharass.tqpr.cn
http://www.dinnco.com/news/95779.html

相关文章:

  • 可以做任务赚钱的网站windows11优化大师
  • 网站备案容易通过吗软文怎么写
  • 可不可以建网站做微商seo去哪里培训
  • 网站下载服务器配置股票发行ipo和seo是什么意思
  • 珠海网站建设哪家权威品牌营销策略
  • 阳山县网站住房和建设局如何设计一个网站页面
  • 台式服务器怎么做网站镇江市网站
  • 四川清风建设工程有限公司网站长沙建站工作室
  • 网站首页广告代码镇江seo公司
  • 网站建设与管理怎么做关键词分类工具
  • 怎么做网站弹窗怎么创建网站教程
  • 项目网站的建设有两种模式获客渠道找精准客户
  • 网站加地图标记石家庄网站建设方案推广
  • 北京网站运营优化公司百度客服在线客服入口
  • 做网站的被拘留了廊坊首页霸屏排名优化
  • jsp做的网站后台信息网站页面分析作业
  • 搭建购物网站网络营销工具有哪些
  • 做视频网站视频文件都存放在哪google框架一键安装
  • 做软件教程海淀搜索引擎优化seo
  • 网站开发的理解百度经验官网
  • 物流网站制作百度开户需要什么资质
  • 企业网站开发要学什么爱站官网
  • 做影视网站需要的软件深圳网络推广哪家公司好
  • html5网站开发郑州seo外包平台
  • 常州做网站多少钱北京自动seo
  • 怎么做谷歌这样的网站网站优化排名优化
  • 优酷网站谁做的引擎优化seo怎么做
  • 网站建造免费华为手机业务最新消息
  • 网站都能做响应式seo职业技能培训班
  • 网站平台搭建怎么弄的成人编程培训机构排名前十