首页下载资源后端request库练习代码

ZIPrequest库练习代码

weixin_6131924542.06KB需要积分:1

资源文件列表:

request库练习.zip 大约有58个文件
  1. request库练习/.git/
  2. request库练习/.git/config 309B
  3. request库练习/.git/description 73B
  4. request库练习/.git/HEAD 23B
  5. request库练习/.git/hooks/
  6. request库练习/.git/hooks/applypatch-msg.sample 478B
  7. request库练习/.git/hooks/commit-msg.sample 896B
  8. request库练习/.git/hooks/fsmonitor-watchman.sample 4.62KB
  9. request库练习/.git/hooks/post-update.sample 189B
  10. request库练习/.git/hooks/pre-applypatch.sample 424B
  11. request库练习/.git/hooks/pre-commit.sample 1.6KB
  12. request库练习/.git/hooks/pre-merge-commit.sample 416B
  13. request库练习/.git/hooks/prepare-commit-msg.sample 1.46KB
  14. request库练习/.git/hooks/pre-push.sample 1.34KB
  15. request库练习/.git/hooks/pre-rebase.sample 4.78KB
  16. request库练习/.git/hooks/pre-receive.sample 544B
  17. request库练习/.git/hooks/push-to-checkout.sample 2.72KB
  18. request库练习/.git/hooks/sendemail-validate.sample 2.25KB
  19. request库练习/.git/hooks/update.sample 3.56KB
  20. request库练习/.git/index 1.85KB
  21. request库练习/.git/info/
  22. request库练习/.git/info/exclude 240B
  23. request库练习/.git/logs/
  24. request库练习/.git/logs/HEAD 189B
  25. request库练习/.git/logs/refs/
  26. request库练习/.git/logs/refs/heads/
  27. request库练习/.git/logs/refs/heads/master 189B
  28. request库练习/.git/logs/refs/remotes/
  29. request库练习/.git/logs/refs/remotes/origin/
  30. request库练习/.git/logs/refs/remotes/origin/HEAD 189B
  31. request库练习/.git/objects/
  32. request库练习/.git/objects/info/
  33. request库练习/.git/objects/pack/
  34. request库练习/.git/objects/pack/pack-363343e641256dd2cce6721d1a8309e158712e4f.idx 1.79KB
  35. request库练习/.git/objects/pack/pack-363343e641256dd2cce6721d1a8309e158712e4f.pack 10.11KB
  36. request库练习/.git/objects/pack/pack-363343e641256dd2cce6721d1a8309e158712e4f.rev 160B
  37. request库练习/.git/packed-refs 114B
  38. request库练习/.git/refs/
  39. request库练习/.git/refs/heads/
  40. request库练习/.git/refs/heads/master 41B
  41. request库练习/.git/refs/remotes/
  42. request库练习/.git/refs/remotes/origin/
  43. request库练习/.git/refs/remotes/origin/HEAD 32B
  44. request库练习/.git/refs/tags/
  45. request库练习/.git/sourcetreeconfig.json 781B
  46. request库练习/DELETE请求.py 332B
  47. request库练习/GET带参.py 519B
  48. request库练习/GET请求.py 223B
  49. request库练习/POST请求.py 682B
  50. request库练习/POST请求扩展(data与json区别).py 1005B
  51. request库练习/POST请求扩展(响应对象.text和.json的区别).py 854B
  52. request库练习/PUT请求.py 695B
  53. request库练习/练习/
  54. request库练习/练习/code.jpg 12.24KB
  55. request库练习/练习/code.png 1.35KB
  56. request库练习/练习/查询我的订单.py 938B
  57. request库练习/练习/查询我的订单_session.py 958B
  58. request库练习/响应对象方法.py 664B

资源介绍:

request库练习代码
# 请求地址:http:127.0.0.1:8000/api/departments/ # 请求信息头:Content-Type: application/json import json # json格式 # 导包 import requests # 调用Post方法 # 请求url url = 'http:127.0.0.1:8000/api/departments/' # 请求headers headers = {'Content-Type': 'application/json'} # 请求json data = { "data": [ { "dep_id": "TT701", "dep_name": "Test学院", "slogan": "Test-Master", "master_nane": "Here is Slogan" } ] } # json使用 ---> 成功 # response = requests.post(url,json=data,headers=headers) # data使用 ---> 失败 注意:对于python字典和json一样,但数据序列化格式还是有一定的区别 # response = requests.post(url,data=data,headers=headers) # 将字典转换为json字符串 response = requests.post(url,data=json.dump(data),headers=headers) # 获取响应对象 print(response.json()) # 获取响应状态码 print(response.status_code)
100+评论
captcha