[英]Run subprocess.call(cmd) while the cmd is a text variable
In python, is it possible to run a shell command, while the command stored in variable as text ? 在python中,是否可以运行shell命令,而该命令以文本形式存储在变量中? for example:
例如:
self.command_editor = QTextEditor()
self.command_editor.append("echo command")
cmd = str(self.command_editor.toPlainText())
call(cmd)
this code doesn`t work! 此代码不起作用!
this is the right answer: 这是正确的答案:
self.command_editor = QTextEditor()
self.command_editor.append("echo command")
cmd = str(self.command_editor.toPlainText())
call(cmd, shell = True) #the mistake was here
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.