Python subprocess.Popen 带有 var/args [英] Python subprocess.Popen with var/args
本文介绍了Python subprocess.Popen 带有 var/args的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想用一个变量调用 subprocess.Popen cmd,但由于原因它不能正常工作
i want to call a subprocess.Popen cmd with a variable but for reason it's not properly working
这就是我得到的错误:
...
谢谢和亲切的问候
推荐答案
所有参数都必须在一个列表中,如
All args have to be in a list like
check_addr = subprocess.Popen(['My command', user.acc_addr], shell=True, stdout=subprocess.PIPE).communicate()[0].decode('utf-8').strip()
# or for example
subprocess.run(["ls", "-l"])
这篇关于Python subprocess.Popen 带有 var/args的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文