我想要返回任何但是这给了我一个错误 我不想返回空字符串
def read_line2(self, timeout=None): ## Read Radio2 Serial line
try:
return self._rq2.get(block=timeout, timeout=timeout)
except Empty:
return ''
答案 0 :(得分:0)
在python中返回None,只需return None
。
def returns_none():
return None
x = returns_none()
assert x is None
我认为您的问题与except Empty:
有关。是否为您已定义的自定义异常,因为它不是内置的python。