【发布时间】:2026-02-04 13:05:01
【问题描述】:
我得到了这样的代码。
....
class SocketWatcher(Thread):
....
def run(self):
....
TicketCounter.increment() # I try to get this function
...
....
class TicketCounter(Thread):
....
def increment(self):
...
当我运行程序时出现此错误。
TypeError: unbound method increment() must be called with TicketCounter instance as first argument (got nothing instead)
我有什么方法可以从 TicketCounter 类调用 increment() 函数到 SocketWatcher 类?还是我的电话有误...
【问题讨论】:
-
评论很明显。你可以阅读它并在谷歌上搜索一下以得到答案。