我正在使用twilio-python,并遵循本教程:http://readthedocs.org/docs/twilio-python/en/latest/usage/twiml.html?highlight=nest
但是当我尝试这个的时候:
from twilio import twiml
r = twiml.Response()
r.say("hello")
with r.gather(finishOnKey=4) as g:
g.say("world")
print str(r)但我得到的是:
AttributeError: __exit__有什么想法吗?
发布于 2011-09-29 11:08:07
它们似乎与with语句并不真正兼容。试试这个:
from twilio import twiml
r = twiml.Response()
r.say("hello")
g = r.gather(finishOnKey=4)
g.say("world")
print str(r)下面是我得到的结果:
>>> from twilio import twiml
>>>
>>> r = twiml.Response()
>>> r.say("hello")
<twilio.twiml.Say object at 0x1098d05d0>
>>> g = r.gather(finishOnKey=4)
>>> g.say("world")
<twilio.twiml.Say object at 0x1098d0950>
>>> print str(r)
<?xml version="1.0" encoding="UTF-8"?><Response><Say>hello</Say><Gather finishOnKey="4"><Say>world</Say></Gather></Response>发布于 2011-09-30 04:36:47
埃米特--接得好。
马特-音调完美的反应。
我们刚刚在3.3.2版本中推出了这个问题的修复-你可以在PyPi上或者在这里的GitHub repo上找到它:
https://github.com/twilio/twilio-python
只需更新你的模块,文档化的方法就会起作用。请发一封电子邮件到我个人资料中的地址-你们刚刚赢得了一件Twilio T恤。:)
https://stackoverflow.com/questions/7591009
复制相似问题