2024-09-22 16:29:53 发布
网友
在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
这是正确的答案:
相关问题 更多 >
编程相关推荐