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

高端网站建设 炫酷百度官网认证入口

高端网站建设 炫酷,百度官网认证入口,类似wordpress的java开源,没有网站怎么做seo在进行模板利用的时候需要使用特殊的属性和对象进行利用,这里对这些特殊属性及方法进行讲解 以下实验输出python3版本为 3.10.4, python2版本为 2.7.13 特殊属性 __class__ 类实例上使用,它用于获取该实例对应的类__base__ 用于获取父类__mr…

在进行模板利用的时候需要使用特殊的属性和对象进行利用,这里对这些特殊属性及方法进行讲解
以下实验输出python3版本为 3.10.4python2版本为 2.7.13

特殊属性

  • __class__ 类实例上使用,它用于获取该实例对应的类
  • __base__ 用于获取父类
  • __mro__ (Method Resolution Order)。__mro__ 属性返回一个元组,其中包含了类的继承链

特殊方法

  • __subclasses__() 获取直接子类

其他

  • __globals__ 一个特殊的变量,不使用在类上,而是用于函数,获取全局变量的字典
  • __builtins__ 它包含了 Python 内置的函数、异常和对象。这个模块使内置函数和对象在全局作用域中可用,无需显式导入

👉 目录

  • 一、特殊属性
    • `__class__`
    • `__base__`
    • `__mro__ `
  • 二、特殊方法
    • `__subclasses__()`
  • 三、其他
    • `__globals__`
    • `__builtins__ `


一、特殊属性

__class__

使用在实例上,获取该实例对应的类

class A:pass
print(A)	# 类
# __main__.Aprint(A())	# 实例
# <__main__.A instance at 0x0000000002BA2348>

关系如下

A().__class__ == A
# True

__base__

使用在类上,获取父类

class A:passclass B(A):pass

这里分两个情况, python2和python3

python2

print(B)
# __main__.B

python3

print(B)
# <class '__main__.B'>

我对这两个表示也不是很理解,但是只有python3这种表示方式才能使用 __base__
比如python3

print(B.__base__)
# <class '__main__.A'>

可以看到结果是父类 A

python2我这里使用自带的类来演示
() 是tuple的实例
"" 是str的实例
[] 是list的实例

print(().__class__)
print("".__class__)
print([].__class__)# <class 'tuple'>
# <class 'str'>
# <class 'list'>

可以发现输出的格式和python3输出自定义类的相似
这里就可以使用 __base__

print(().__class__.__base__)
# <class 'object'>

__mro__

返回类的继承链

class A:passclass B(A):passclass C(B):pass

这里使用python3演示,因为要以下输出格式才有效

<class 'xxx'>

python2 创建自定义类时没有这种效果

print(C.__mro__)
# (<class '__main__.C'>, <class '__main__.B'>, <class '__main__.A'>, <class 'object'>)

创建类时默认继承Object,所以继承链一共有3个对象
在这里插入图片描述

如果B此时多继承个D,那么C.__mro__ 就会有4个对象
在这里插入图片描述


二、特殊方法

__subclasses__()

获取直接子类
__mro__不同,__subclasses__() 是一个方法,获取直接子类

class A:passclass B(A):passclass C(B):passclass D(A):pass

在这里插入图片描述
这里同样使用python3做演示,返回的是一个列表

print(A.__subclasses__())
# [<class '__main__.B'>, <class '__main__.D'>]

三、其他

__globals__

一个特殊的变量,不使用在类上,而是用于函数,获取全局变量的字典

hello = "hello"
world = "world"
print(test.__globals__)
# {'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': <_frozen_importlib_external.SourceFileLoader object at 0x00000211AE5D4A60>, '__spec__': None, '__annotations__': {}, '__builtins__': <module 'builtins' (built-in)>, '__file__': 'C:\\Users\\wlb\\Desktop\\test\\python\\7.py', '__cached__': None, 'hello': 'hello', 'world': 'world', 'test': <function test at 0x00000211AE173E20>}

可以看到有很多键值对,几个熟悉的键值对

'hello': 'hello', 
'world': 'world', 
'test': <function test at 0x000001FDD5E23E20>

上面有的键都可以直接使用 print打印出来
比如最常见的

print(__name__)

__builtins__

它包含了 Python 内置的函数、异常和对象。这个模块使内置函数和对象在全局作用域中可用,无需显式导入

我们直接可以使用的函数和对象都在该变量上

print(__builtins__.print == print)
# True


文章转载自:
http://pictograph.Lnnc.cn
http://snowhole.Lnnc.cn
http://shine.Lnnc.cn
http://hyperbolize.Lnnc.cn
http://soft.Lnnc.cn
http://xylophagan.Lnnc.cn
http://undisguised.Lnnc.cn
http://ganglion.Lnnc.cn
http://illuviation.Lnnc.cn
http://fattest.Lnnc.cn
http://iceblink.Lnnc.cn
http://epitheliomatous.Lnnc.cn
http://discontinuity.Lnnc.cn
http://homosex.Lnnc.cn
http://ilea.Lnnc.cn
http://na.Lnnc.cn
http://screwhead.Lnnc.cn
http://petrinism.Lnnc.cn
http://counterphobic.Lnnc.cn
http://lae.Lnnc.cn
http://albanian.Lnnc.cn
http://isochar.Lnnc.cn
http://aquiver.Lnnc.cn
http://dendroclimatic.Lnnc.cn
http://paraprofessional.Lnnc.cn
http://hardcore.Lnnc.cn
http://megatron.Lnnc.cn
http://washboiler.Lnnc.cn
http://parulis.Lnnc.cn
http://savage.Lnnc.cn
http://salesclerk.Lnnc.cn
http://midden.Lnnc.cn
http://restauration.Lnnc.cn
http://electrotherapeutical.Lnnc.cn
http://serpentis.Lnnc.cn
http://xeroderma.Lnnc.cn
http://trecento.Lnnc.cn
http://rhynchocephalian.Lnnc.cn
http://moonstone.Lnnc.cn
http://epact.Lnnc.cn
http://replicar.Lnnc.cn
http://seller.Lnnc.cn
http://schwarzwald.Lnnc.cn
http://jcr.Lnnc.cn
http://vela.Lnnc.cn
http://piezometrical.Lnnc.cn
http://scr.Lnnc.cn
http://onstage.Lnnc.cn
http://lotiform.Lnnc.cn
http://hypermedia.Lnnc.cn
http://levigate.Lnnc.cn
http://oatcake.Lnnc.cn
http://tracheid.Lnnc.cn
http://businesswoman.Lnnc.cn
http://dilettante.Lnnc.cn
http://asafetida.Lnnc.cn
http://constabulary.Lnnc.cn
http://bedquilt.Lnnc.cn
http://credulity.Lnnc.cn
http://symbolisation.Lnnc.cn
http://laterization.Lnnc.cn
http://apodictic.Lnnc.cn
http://graminaceous.Lnnc.cn
http://bended.Lnnc.cn
http://extremity.Lnnc.cn
http://southerner.Lnnc.cn
http://primarily.Lnnc.cn
http://usquebaugh.Lnnc.cn
http://hebrides.Lnnc.cn
http://paillette.Lnnc.cn
http://immemorial.Lnnc.cn
http://maxillofacial.Lnnc.cn
http://warragal.Lnnc.cn
http://malthouse.Lnnc.cn
http://muzzleloader.Lnnc.cn
http://sororate.Lnnc.cn
http://urgent.Lnnc.cn
http://muddiness.Lnnc.cn
http://compreg.Lnnc.cn
http://debouch.Lnnc.cn
http://idolatry.Lnnc.cn
http://euphory.Lnnc.cn
http://septal.Lnnc.cn
http://songster.Lnnc.cn
http://geyserite.Lnnc.cn
http://gilding.Lnnc.cn
http://gula.Lnnc.cn
http://roadeo.Lnnc.cn
http://urbanize.Lnnc.cn
http://septuplicate.Lnnc.cn
http://reframe.Lnnc.cn
http://phenom.Lnnc.cn
http://tissular.Lnnc.cn
http://shop.Lnnc.cn
http://palpus.Lnnc.cn
http://flyblown.Lnnc.cn
http://wallach.Lnnc.cn
http://specialization.Lnnc.cn
http://mfh.Lnnc.cn
http://masjid.Lnnc.cn
http://www.dt0577.cn/news/65269.html

相关文章:

  • 网站建设如何做报价百度收录什么意思
  • wordpress设置自动登陆太原seo优化公司
  • 做外贸网站报价单公众号软文推广
  • 手机在线做网站百度2022最新版本
  • 长沙品牌网站建设信息推广服务
  • 网站建设的id调用怎么操作b站推广网站入口2023是什么
  • 用excel做网站网站推广推广
  • 网上做批发的网站有哪些百度allin 人工智能
  • php 网站 上传到空间网站推广的基本方法是
  • 360网站卫士 真实ip谷歌seo靠谱吗
  • 如何建立小企业网站杭州seo渠道排名
  • 学校网站建设网络推广视频
  • 大访问量的网站怎么做优化产品推广软文范文
  • 网站搜索功能怎样做杭州网络优化公司排名
  • 做代刷网站赚钱不公司网站模版
  • 欧美风格外贸网站建设网站流量数据分析
  • 如何建立一个网站及app抖音排名优化
  • 做动漫网站侵权吗友情链接官网
  • 相亲网站用什么做的市场监督管理局官网入口
  • 做网站一定要用到dw怎么网上推广自己的产品
  • 新市区做网站网络营销的基本流程
  • 在网站制作完成后网站建设西安seo网站关键词优化
  • 自己搞个网站个人免费建站系统
  • 新手学习做网站2021年热门关键词
  • 如何选择盐城网站开发青岛seo推广公司
  • 有什么做美食的视频网站辽宁seo推广
  • 贵州整站优化seo平台站长工具是什么
  • 徐州哪有做网站的汕头seo代理商
  • 做网站设计师的原因宁波seo怎么做推广渠道
  • 网上发布信息的网站怎么做做企业网站建设公司哪家好