self.clearButton.clicked.connect(host.clear(self))
self.clearButton.clicked.connect(host.clear(self))
TypeError: argument 1 has unexpected type 'NoneType'
修改為:
self.clearButton.clicked.connect(lambda:host.clear(self))
def clear(self):
self.textBrowser.clear()
Lambda的基础用法详见Python Lambda,以及請參考从零开始学python | 什么是Lambda函数以及如何使用它们?
本文介绍了在Python中遇到`TypeError: argument 1 has unexpected type 'NoneType'`错误的原因及解决方案。通过修改`self.clearButton.clicked.connect(host.clear(self))`为`self.clearButton.clicked.connect(lambda: host.clear(self))`,成功解决了问题。同时,文章还提到了Lambda函数的基本用法和其在Python编程中的应用。
5966

被折叠的 条评论
为什么被折叠?



