程式執行有時會發生錯誤
unknown700831 opened this issue · comments
unknown700831 commented
我在執行以下程式時
xstock=twstock.realtime.get('1101')
realtime=xstock.get('realtime')
xopen=realtime.get('open')
xprice=realtime.get('latest_trade_price')
xvolume=realtime.get('accumulate_trade_volume')
有時候會出現以下問題
xopen=realtime.get('open')
AttributeError: 'NoneType' object has no attribute 'get'
不知道是哪裡的問題呢?
Louie Lu commented
這代表前面的 xstock
裡面沒有 open
這個 key-value pair,導致你的 realtime 其實是 None。而 None 並沒有 .get
這個 method,所以才會出現 AttributeError。