首页 > 解决方案 > 在我的 python 代码中停止 subprocess.call 循环

问题描述

def raspi_connecter():
    print("Below is the output from the shell script in terminal")
    subprocess.call('ssh dev@X.0.0.X', shell=True)

该代码在我的 GUI 程序中打开了我的 raspi,但是当我点击窗口上的其他按钮(执行命令、更新、导入文件)时,我的 mac 出现了彩虹死亡之轮。我认为这是因为它被困在一个开环中,但也许是错的?

Popen 会比 .call 更好吗?

标签: pythonsubprocess

解决方案


使用 Popen 应该是解决办法。查看文档以获取更多信息 https://docs.python.org/3/library/subprocess.html


推荐阅读