烧瓶:在要求中通过JSON中的布尔值
使用Python 请求
库,我如何在请求主体中发送布尔值?我已经尝试过:
request_body = {'somebooleanvalue':true}
。 =>名称:名称'true'未定义
request_body = {'somebooleanvalue':true}
=>只有Unicode对象是可以逃脱的。 type< class“ bool”>。
谢谢!
Using the Python requests
library, how can I send a boolean value in request body? I've tried:
request_body = {'someBooleanValue': true}
. => NameError: name 'true' is not defined
request_body = {'someBooleanValue': True}
=> Only unicode objects are escapable. Got True of type <class 'bool'>.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以在请求方法中的json参数中传递带有布尔值的字典:
您也可以在此处执行json = request_body
,我看不到烧瓶与这个问题有什么关系 - 请求库是一个单独的python库,而不是与烧瓶。让我知道我是否在这里误解了一些东西。
you can pass the dictionary with boolean values as the json parameter in the request method:
you can do json=request_body here
Also, I dont see what flask has to do with this question - the requests library is a separate python library and not related to flask. Let me know if I misunderstood something here.