[英]Error in Jupyter notebook “IndentationError: expected an indented block”
[英]How to solve “IndentationError: expected an indented block” in Jupyter when importing a module?
我對 Python 和 Jupyter Notebook 很陌生,遇到了一些問題。 昨天,我創建了一個名為“edhec_risk_kit”的“工具包”,它包含了我在處理新項目時希望調用的所有函數。 該文件的位置是:
“/Users/MyName/Ptf.construction and Analysis with Python/edhec_risk_kit.py 簡介”
現在我正在嘗試將工具包“導入”為 Jupyter Notebook,但我收到以下錯誤消息:
Traceback (most recent call last):
File "/Users/MyName/opt/anaconda3/lib/python3.7/site-packages/IPython/core/interactiveshell.py", line 3331, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-1-d8b39bc3a411>", line 1, in <module>
import edhec_risk_kit as RiskKit
File "/Users/MyName/Intro to Ptf.construction and Analysis with Python/edhec_risk_kit.py", line 123
'''
^
IndentationError: expected an indented block
我究竟做錯了什么? 昨晚我能夠導入“工具包”,但現在我只收到錯誤消息
檢查工具包文件的第 123 行。
File "/Users/MyName/Intro to Ptf.construction and Analysis with Python/edhec_risk_kit.py", line 123
'''
^
IndentationError: expected an indented block
我同意另一個答案(我贊成),另外請注意您需要小心使用'''
,它的縮進級別需要與正常的新代碼行相同(與#
不同,您可以插入任意位置)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.