如何 运行 在 VSCode 中加载 Python Interactive window 时启动命令

How to run startup commands on loading Python Interactive window in VSCode

我正在尝试在 VSCode 中启动或重置 Python Interactive Window (IPython) 之前执行一些启动命令。 由于我检查了文档和参数设置,我能够识别正确的参数:

Python > Data Science: Run Startup Commands

A series of Python instructions or iPython magic commands separated by '\n' that will be executed when the interactive window loads. For instance, set this to '%load_ext autoreload\n%autoreload 2' to automatically reload changes made to imported files without having to restart the interactive session.

但是,当我插入我想要的 python 命令时,它们没有按预期工作。例如,我尝试加载插入 'import numpy as np' 的 numpy 包,但是当我开始一个新的 Python Interactive Window 时,它输出:

np is not defined

我做错了什么?谢谢!

删除引号 '',只是 import numpy as np,并且不要忘记用 \n.

分隔指令