我试图在UbuntuServer13.0和Python2.7中运行以下python代码
from twisted.python.log import err
from twisted.web.client import Agent
from twisted.internet import reactor
from twisted.internet.ssl import ClientContextFactory
from twisted.web.http_headers import Headers
from stringproducer import StringProducer
class WebClientContextFactory(ClientContextFactory):
def getContext(self, hostname, port):
return ClientContextFactory.getContext(self)
def display(response):
print "Received response"
print response
def main():
contextFactory = WebClientContextFactory()
agent = Agent(reactor, contextFactory)
d = agent.request("POST", "https://myweburl");
d.addCallbacks(display, err)
d.addCallback(lambda ignored: reactor.stop())
reactor.run()
if __name__ == "__main__":
main()
当我试图运行它时,它给出了以下错误:
^{pr2}$我在python控制台中尝试过扭曲的互联网有用,但不行扭曲的.web. 有人对如何处理这种问题有什么建议吗?在
谢谢
你安装了twisted web吗?您必须在Ubuntu下安装
python-twisted-web
包:相关问题 更多 >
编程相关推荐