当我运行此代码时:
i=0
while i<5:
i=i+1;
try:
SellSta=client.get_order(symbol=Symb,orderId=SellOrderNum,recvWindow=Delay)
except client.get_order as e:
print ("This is an error message!{}".format(i))
#End while
我收到了这个错误:
TypeError: catching classes that do not inherit from BaseException is not allowed
我读到这个异常类型错误警告有时会显示,有时在使用生成器的 throw 方法时不会显示,而这个Can't catch mocked exception 因为它不继承 BaseException也读过这个https://medium.com/python-pandemonium/a -非常挑剔的python-d9b994bdf7f0除外
我用这段代码修复它:
i=0
while i<5:
i=i+1;
try:
SellSta=client.get_order(symbol=Symb,orderId=SellOrderNum,recvWindow=Delay)
except:
print ("This is an error message!{}".format(i))
#End while
结果是忽略错误并转到下一个,但我想捕获错误并打印它。