mlouielu / twstock

台灣股市股票價格擷取 (含即時股票資訊) - Taiwan Stock Opendata with realtime

Home Page:http://twstock.readthedocs.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

程式執行有時會發生錯誤

unknown700831 opened this issue · comments

我在執行以下程式時
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'

不知道是哪裡的問題呢?

這代表前面的 xstock 裡面沒有 open 這個 key-value pair,導致你的 realtime 其實是 None。而 None 並沒有 .get 這個 method,所以才會出現 AttributeError。