![](/img/trans.png)
[英]Python Class Confusion: How to print object attributes returned by a function
[英]How to access the object returned by a function inside python class
我有以下 python class:
class Example(QMainWindow):
def onChanged(self, text):
return text
def buttonClicked(self):
print(self.onChanged)
当我运行脚本时,我得到以下结果:
<bound method Example.onChanged of <__main__.Example object at 0x7fde1cab0550>>
我的问题是如何获取onChanged
function中返回的文本内容?
谢谢你。
执行print(self.onChanged)
时不要调用 function,而应执行print(self.onChanged())
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.