我是Python和Jupyter Notebook的新手,我遇到了一些问题。昨天,我创建了一个名为“ edhec_risk_kit”的“工具箱”,其中包含在开发新项目时希望调用的所有功能。该文件的位置是:
“ / Users / MyName /使用Python / edhec_risk_kit.py介绍Ptf.construction和分析。
现在我正尝试将工具箱“导入”为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
我同意另一个答案(我赞成),另外请注意,使用'''
需要小心,其缩进级别必须与普通的新代码行相同(与#
不同,您可以将其插入任何位置)