我有个无法解决的问题。我知道错误了
UnboundLocalError: local variable 'checking' referenced before assignment
我的代码
def volume_checker_first_stage(volume1,volume2,withdraw_minimun):
if volume1>volume2:
quantity = volume2
if quantity > withdraw_minimun:
checking = True
return quantity, checking
elif volume2>volume1:
quantity = volume1
if quantity > withdraw_minimun:
checking = True
return quantity, checking
else:
return None,None
将
checking
初始化为False
作为函数中的第一行,以避免此错误。在作为函数主体的第一行,请编写以下代码:
您有一个返回
return
值的return
语句,但您的代码并不总是设置它。Referenced before assignment
表示您的return
语句在代码分配变量之前请求它的值。在相关问题 更多 >
编程相关推荐