python - 如何在 python 中使用存储的变量进行发布请求
问题描述
尝试在 python 中发出 post 请求,我收到此错误
import requests
token='Bearer aslkdjndskgns'
endpoint = "https://aap.xyz"
phone_number='9177903753951'
data = {"number":phone_number}
datas = str(data)
headers={"authorization":token}
a=(requests.post(endpoint, data=datas, headers=headers).json())
我收到这个错误
invalid character 'p' looking for beginning of value "
解决方案
请尝试以下代码,看看它是否解决了您的问题。
import requests
token='Bearer aslkdjndskgns'
endpoint = 'https://aap.xyz'
data = {'number':'9177903753951'}
headers={"authorization":token}
a=(requests.post(endpoint, data=data, headers=headers).json())
print(a)
推荐阅读
- javascript - Material UI Texboxes Dynamically created form Array Disply in multi columns ReactJs
- javascript - 如何使用鼠标悬停显示内容
- maven - 如何在 IntelliJ 中调试 Maven OpenJFX 应用程序
- javascript - 如何使用 CSS、HTML 和 javascript 将菜单从父菜单折叠和展开到子菜单?
- css - 背景图像的相对 URL 导致语法错误
- java - 尝试从 AWS windowsInstance 下载时 JKS 文件损坏
- python - 从 Pytorch 中的 Resnet 模型中删除 RELU 激活
- r - ifelse 在 r 中给出了设计之外的答案,表现得很奇怪
- reactjs - react-native-device-info `getUniqueId()` 是否提供 UUID 或 GUID?
- c# - 用不同的内部for循环重构两个相似的函数