Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在 python 中,是否可以运行 shell 命令,而命令以文本形式存储在变量中?例如:
self.command_editor = QTextEditor() self.command_editor.append("echo command") cmd = str(self.command_editor.toPlainText()) call(cmd)
此代码不起作用!
这是正确的答案:
self.command_editor = QTextEditor() self.command_editor.append("echo command") cmd = str(self.command_editor.toPlainText()) call(cmd, shell = True) #the mistake was here