[英]How should I preferably "run" Python scripts in RStudio? Through run (using reticulate::repl_python()?) or source?
我剛開始使用 RStudio 和 Python(到目前為止一切正常),我想知道是否有更好的方式來運行腳本,例如我的小Test.py
包含
import inspect
import os
a = 5
print(a)
print(inspect.currentframe())
os.chdir("C:/.../") # a path, whatever you like
cwd = os.getcwd()
# print the current directory
print("Current working directory is:", cwd)
此處有 R 的答案,但這不考慮 Python。我嘗試了以下操作:
reticulate::repl_python()
啟動 Python 控制台 => 從 R- 更改為 Python-console 似乎reticulate::repl_python()
首先強制quit
。
This reference for reticulate and its description did not help : The reticulate package provides a comprehensive set of tools for interoperability between Python and R... Reticulate embeds a Python session within your R session, enabling seamless, high-performance interoperability.
(評論太長了。也許它可以幫助別人,希望一切都是正確的)
據我所知,RStudio 為 R 提供了一個編輯器(不足為奇)。 當您在 RStudio 中運行 Python 代碼時,有一個 Python 的 R-wrapper 將代碼轉換為 R。
因此,RStudio 不會將編輯器切換到原生 Python-IDE(這是我的期望),如 VScode 或其他。
我現在的理解是:如果您只有 Python 的項目,請使用 Python 編輯器。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.