【发布时间】:2011-11-18 00:39:33
【问题描述】:
我有一个使用 Twisted 框架编写的 Python Bot,我有一个输出特定文本的 C 程序。如果 Twisted 使用命令运行 C 程序,收集输出,然后将输出打印回给我,我将如何运行?
【问题讨论】:
标签: python c linux twisted irc
我有一个使用 Twisted 框架编写的 Python Bot,我有一个输出特定文本的 C 程序。如果 Twisted 使用命令运行 C 程序,收集输出,然后将输出打印回给我,我将如何运行?
【问题讨论】:
标签: python c linux twisted irc
最简单的方法是getProcessOutput:
from twisted.internet.utils import getProcessOutput
df = getProcessOutput('ls', args=('/home','-lah'))
df.addCallback( printOutput )
如果您需要更复杂的东西,另请参阅 http://twistedmatrix.com/documents/current/core/howto/process.html。
【讨论】: