python-3.x - 我正在尝试调用 cloudflare api“创建列表项”,但出现错误“需要类似字节的对象,而不是 'str'”。我如何解决它
问题描述
import json import requests ip = input('Put IP here:') comment = input('Put comment here:')
url = "https://api.cloudflare.com/client/v4/accounts/xxxxxxxxxxxxxx/rules/lists/xxxxxxxxxxxxxx/items" 有效载荷 = {(ip),(comment)}
headers = {“content-type”:“application/json”,“Accept-Charset”:“UTF-8”,“X-Auth-Email”:“xxxxxxxxxxxxx”,“X-Auth-Key”:“xxxxxxxxxx” }
response = requests.post(url,data=payload, headers=headers) 打印 (response.txt)
解决方案
推荐阅读
- angular - 不断变化的数据中的按钮单击问题
- python - 如何在 selenium python 或使用 selenium 库的机器人框架中使用鼠标放大网页?
- nginx - NGINX 没有路由到 net core 项目(端口不是 80)
- python - 如何在python中将字符串值调用到sql查询中
- javascript - 无法通过“Content-Type”发送 JSON 对象:“application/x-www-form-urlencoded
- git - git pull 请求和远程分支关系
- google-cloud-datastore - 属性值不变时更新期间的索引开销
- javascript - Angular - 将 https 请求结果合并到同一个数组中
- json - jq summarize similar elements
- angularjs - 角度:如果 val > val 则应用 css 类