2021-01-16 Python 筆記

  1. What does |= (ior) do in Python?
  2. UnicodeDecodeError, invalid continuation byte (encoding="latin-1")
  3. 使用 Python typing 模組對你的同事好一點 (from typing import List)
  4. 淺述 python 中 numpy.argsort() 函式的例項用法
  5. What does the “at” (@) symbol do in Python?
  6. pandas.DataFrame concat 後記得 reset_index

500 – internal server error

ERROR

以 pandas_datareader 和 bokeh 製作股價 K 線圖時

在 Localhost 運作正常

但部屬到 Heroku 上時就會出現 internal server error

Heroku Logs

File "/app/script1.py", line 67, in plot

css_url = CDN.css_files[0]

IndexError: list index out of range

顯然問題是出在

css_url = CDN.css_files[0]

解決辦法

在 jupyter notebook 上確實要抓第一個 index 才是正確的 CSS 連結

但把 [0] 刪掉後就不會出現 500 error

css_url = CDN.css_files

2017.8.30 Errors


“break" ouside the loop

break 不能用來中止 if statement,而是中止 Loop


unindent does not match any outer indentation level

新的 python 語法中,代碼縮進 (indentation) 不支援 Tab 和 Space 混用


name ‘raw_input’ is not defined

python 3 只需要 ‘input‘ 即可,沒有 ‘raw_input’