Django/Python 发布
首先进行一些介绍。我将发送一个 POST 到一个 url,它将有 IP、MAC 或主机名。现在,根据 QueryDict 中的哪个键,我希望它执行某些调用。即:
输出
print request.POST
<QueryDict: {u'ip': [u'10.1.24.178'], u'message': [u'Test'], u'client': [u'auabrthin1']}>
我想写这样的
if request.POST['client'] in request.POST:
do_something()
:但是 request.POST['client']
显然是 client 的值我如何检查 request.POST 是否有密钥?
First a bit of an introduction. I will send a POST to a url and it will have either
ip, mac or hostname. Now depending on which of these key' are in the QueryDict i want it to do certain calls. I.e:
Output of
print request.POST
<QueryDict: {u'ip': [u'10.1.24.178'], u'message': [u'Test'], u'client': [u'auabrthin1']}>
I want to write something like this:
if request.POST['client'] in request.POST:
do_something()
however request.POST['client']
obviously is the value of client how can I check if a request.POST has a key?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)