[英]How do I run a command in a Jupyter notebook?
In a notebook I have the following in a cell: 在笔记本中,单元格中包含以下内容:
cwd = os.getcwd()
run cwd + "/plot_data.py"
I get the error: 我得到错误:
ERROR:root:File `'cwd.py'` not found.
Apparently, run thinks I am trying to run a python file "cwd.py" with the options "+" and "plot_data.py". 显然,run认为我正在尝试运行带有选项“ +”和“ plot_data.py”的python文件“ cwd.py”。
Actually I am trying to run a file plot_data.py located in cwd 实际上我正在尝试运行位于cwd中的文件plot_data.py
Create the full file name, and pass it to run
with the $
prefix: 创建完整的文件名,并传递给它以
$
前缀run
:
file = cwd + "/plot_data.py"
run $file
In 在
run cwd + "/plot_data.py"
cwd
is the file parameter, to be run, and '+' and "/plot..." are arguments that get passed to it. cwd
是要运行的文件参数,“ +”和“ / plot ...”是传递给它的参数。 This isn't a Python expression (which would preform the string join). 这不是Python表达式(它将执行字符串join)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.