我尝试使用 Poloniex 模块将加密货币从我的 Poloniex 钱包提取到 python 中的外部钱包,该模块与以下代码配合得很好:
from poloniex import Poloniex
from poloniex import PoloniexCommandException
polo = Poloniex("my_api_key", "my_api_secret")
try:
r = polo.withdraw(currency = "LTC", amount = "0.5", address = "MH...W5")
except PoloniexCommandException:
print("doesn't work")
else:
print("successful")
print(r["response"])
如果提款过程中没有错误,一切都很好。如果出现错误(我没有足够的余额或地址错误),它将doesn't work
按预期打印。如果我打印r
,我会收到以下错误:
Traceback (most recent call last):
File "c:\Users\phil\Desktop\Python\poloniextest.py", line 12, in <module>
r = polo.withdraw(currency = "LTC", amount = "0.5", address = "MH...W5")
File "C:\Users\phils\AppData\Local\Programs\Python\Python39\lib\site-packages\poloniex\poloniex.py", line 300, in withdraw
return self._private('withdraw', currency=currency, amount=amount,
File "C:\Users\phil\AppData\Local\Programs\Python\Python39\lib\site-packages\poloniex\poloniex.py", line 50, in _fn
raise PoloniexCommandException(respdata['error'])
poloniex.exceptions.PoloniexCommandException: Not enough LTC.
现在我想从错误中打印此消息:Not enough LTC.
是否可以打印此消息?