-1
這是我的錯誤:UnboundLocalError後sys.exit()
Traceback (most recent call last):
File "./datalogger.py", line 208, in <module>
calculateamounttosend()
File "./datalogger.py", line 36, in calculateamounttosend
return send_amount
UnboundLocalError: local variable 'send_amount' referenced before assignment
208行是:
calculateamounttosend()
功能是:
def calculateamounttosend():
wallet_balance = float(subprocess.check_output(['solarcoind', 'getbalance'], shell=False))
if wallet_balance < 0.0005:
print ("*******ERROR: wallet balance of {}SLR too low for reliable datalogging, add more SLR to wallet $
time.sleep(10)
sys.exit
elif wallet_balance >= 10:
send_amount = str(1)
print ('Based on wallet balance of {} amount to send to self set to {} SLR') .format(wallet_balance, se$
elif wallet_balance < 10 and wallet_balance >= 0.03:
send_amount = str(0.01)
print ('Based on wallet balance of {} amount to send to self set to {} SLR') .format(wallet_balance, se$
else:
send_amount = str(0.00001)
print ("*******WARNING: low wallet balance of {}SLR, send amount of {} may result in higher TX fees****$
return send_amount
當WALLET_BALANCE低於0.0005它執行sys.exit(),但後來並沒有真正停止,它似乎讀取了其餘的代碼並給出錯誤。我不清楚爲什麼如果程序退出,我會得到錯誤,如果我有回報,爲什麼它會造成問題。
啊!語法,非常感謝 – Scalextrix
程序必須退出,因爲錢包中沒有足夠的資金來執行程序,但用戶無法對此程序做出改變,他們必須去目標solarcoind並執行某些操作,這可能會需要幾分鐘,幾小時或幾周 – Scalextrix