简体   繁体   English

如何在web.py中查看app.request返回的对象的实例属性?

[英]How can I see instance attributes of the object returned by app.request in web.py?

from bin.app import app

resp = app.request('/')

print resp.__dict__.keys()
print vars(resp)
print resp.__class__.__dict__.keys()

I know app.request returns an object with the data attributes 'headers', 'status' and 'data'. 我知道app.request返回一个具有数据属性“标头”,“状态”和“数据”的对象。 All I want to do is print them out, but none of the print statements above show that these exist. 我要做的就是将它们打印出来,但是上面的打印语句都没有显示这些存在。

Is there some way of finding these attributes (without using the help docs)? 有没有办法找到这些属性(不使用帮助文档)?

存储对象resp具有__getattr__方法(我使用dir(resp)找到dir(resp)您可以使用该方法列出属性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM