0

在 python 中,是否可以运行 shell 命令,而命令以文本形式存储在变量中?例如:

  self.command_editor = QTextEditor()
  self.command_editor.append("echo command")
  cmd = str(self.command_editor.toPlainText())
  call(cmd)

此代码不起作用!

4

1 回答 1

1

这是正确的答案:

  self.command_editor = QTextEditor()
  self.command_editor.append("echo command")
  cmd = str(self.command_editor.toPlainText())
  call(cmd, shell = True) #the mistake was here
于 2013-09-29T16:58:53.633 回答