python - 从另一个 python 脚本获取返回信息

标签 python linux

我在 linux 上,我有一个 python 脚本,我想从另一个 python 脚本调用它。我不想将它作为一个模块导入(为了一层安全,现在为了学术练习,因为我想弄清楚这一点),我实际上想让一个脚本用 os.system() 或另一个类似的函数,并让另一个脚本将元组列表返回给第一个脚本。

我知道这可能不是最佳方式,但我想尝试一下,并在此过程中学习一些东西。

最佳答案

您可以使用 subprocess :

subprocess.call(["python", "myscript.py"])

这也将返回进程返回值(例如 0 或 1)。

关于python - 从另一个 python 脚本获取返回信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16877323/

相关文章:

linux - Buildroot - 建了一个文件系统,如何登录?引导挂起

python - 训练gensim word2vec模型后单词不在词汇表中,为什么?

python - 全局使 Python 字典有序

linux - 删除文件中元素由模式定义的部分行

c - 如何在 Linux 中获取文件创建日期?

linux - Makefile DEFAULT_GOAL 变量

linux - Perl/Linux 用另一个文件的内容过滤大文件

python - 何时在 Python 中使用线程本地内存?

python - 从云函数在 Google Cloud Storage 中创建新的 csv 文件

python - 如果我在任务中发送 http 请求,为什么我的 Airflow 会挂起?