繁体   English   中英

如何在后台使用depentdent shell命令运行python脚本

[英]How to run python script with depentdent shell command in the background

是否可以在python脚本的后台运行shell命令? 假设我有run.py,在这个脚本中我需要做

#run shell command(in python script until script is finished)
#continue with  script

但是问题在于它们是依赖的。 要运行我的脚本,我需要在同一脚本中运行shell命令。

是的,您可以在Python中使用subprocess库并检查输出状态。

例如: subprocess.check_call("exit 1", shell=True)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM