[英]Jupyter notebooks: how to run a terminal command with a python variable input
在我的 Jupyter/IPython 筆記本中,我需要使用 Python 變量作為輸入,從終端命令運行 R 腳本:
x = "Owen"
! Rscript ./sayHello.R x
但是,變量x
未被識別(即不包括 Python 命名空間)。 你如何解決這個問題?
解決方案:將變量括在大括號中:
x = "Owen"
! Rscript ./sayHello.R {x}
或以$
符號為前綴:
x = "Owen"
! Rscript ./sayHello.R $x
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.