TypeError: __main__.print_hello() argument after * must be an iterable, not NoneType
这个错误是因为你没有给 ThreadWrapper
的 args
参数传入一个可迭代对象(iterable),而是传入了 None
。
可以在初始化 ThreadWrapper
对象时,给 args
参数传入一个空的元组 ()
,这样就可以避免这个错误:
import threading
class ThreadWrapper:
def __init__(self, target_func, args=None):
self.target = target_func
self.args = args
self.thread = threading.Thread(target=self.run)
def run(self):
self.target(*self.args)
def start(self):
self.thread.start()
def join(self):
self.thread.join()
def print_hello():
print("Hello World!")
tw = ThreadWrapper(print_hello, ())
tw.start()
tw.join()
这样就可以正常输出 Hello World!
了。
TypeError: ddt.ddt() argument after * must be an iterable, not NoneType
This error occurs when the ddt.ddt()
decorator is not used correctly. The ddt.ddt()
decorator requires an iterable argument, but instead, a NoneType
object was passed.
To fix this error, make sure that the ddt.ddt()
decorator is used with an iterable argument. For example:
import ddt
@ddt.ddt([1, 2, 3])
def test_my_function(input):
# Test code here
In this example, the ddt.ddt()
decorator is used with a list of inputs [1, 2, 3]
, which will be used to run the test_my_function
test case multiple times with different inputs.
TypeError: update_from_modules() argument after * must be an iterable, not NoneType
这个错误是因为在调用 update_from_modules()
函数时,传递了一个 None
类型的参数作为可迭代对象。这个函数需要至少一个可迭代对象作为参数,以便从中更新模型的参数。
可能的原因是你传递了一个空的可迭代对象或者忘记传递参数了。你可以检查一下传递的参数是否正确,或者在调用函数之前检查一下参数是否为空。
相关推荐















