python - super() 接受 2 个相同的类但返回另一个类的方法
问题描述
嗨,我对 Python 的超级函数的语法有一些问题..
class x:
def __init__(self):
pass
class p(x):
def __init__(self):
print(super(p,self).__init__())
输出:
<bound method x.__init__ of <__main__.y object at 0x000001FF918EC898>>
这是 的__init__
方法x
。所以问题是,self
它p
本身在p
。我们调用super(p,self)
,并且通过这种方式我们给p
超级函数两次类,但它返回x
的__init__
方法..怎么样?
解决方案
推荐阅读
- visual-studio-code - 复制粘贴文本时,Visual Studio Code 不断添加输入?
- maven - 跳过“如果需要安装功能扩展”
- jquery - 使用 Laravel 按所选项目显示数据库中的图像
- linux - Linux - rsync 单一副本很好,但多个文件失败
- vue.js - 如何在 Vue.js/Vuetify 中创建警报消息队列?
- azure - “addon-http-application-routing-nginx-ingress-controller”的问题。未找到端点
- react-native - 出现“尝试注册两个具有相同名称 RNCViewpager 的视图”的错误
- azure - 使用 ADF 使用客户端证书进行 REST API 身份验证
- sql-server - 链接服务器测试连接不工作(SQL Server 到 Oracle 数据库)
- amazon-web-services - AWS Glue 映射对来自不同工作流的作业的依赖关系