{ "token": "eyJhbGciOiJIUzUxMiJ9.eyJjbGFpbV9rZXkiOjE2ODY1NDA1NDIyNDUsInVzZXJJZCI6MSwic3ViIjoiYWRtaW4iLCJpYXQiOjE2ODY1NDA1NDIsImV4cCI6MTY4NjU0Nzc0Mn0.hSkWAezgpjEg1vHV8kfXskOVisjIVlVCT9hLXaaiT_zyLsVMwpjPrAUjmxb7Z1gkkLsKoHf1iImSXvLIitz4pQ" }接口返回这个数据我怎么获取其中的token值
时间: 2023-07-19 15:45:56 浏览: 405
token值获取
5星 · 资源好评率100%
这是一个 JSON 格式的数据,你可以使用任何一种编程语言来解析它,然后获取其中的 token 值。以 Python 为例,可以使用以下代码:
```python
import json
response = '{"token": "eyJhbGciOiJIUzUxMiJ9.eyJjbGFpbV9rZXkiOjE2ODY1NDA1NDIyNDUsInVzZXJJZCI6MSwic3ViIjoiYWRtaW4iLCJpYXQiOjE2ODY1NDA1NDIsImV4cCI6MTY4NjU0Nzc0Mn0.hSkWAezgpjEg1vHV8kfXskOVisjIVlVCT9hLXaaiT_zyLsVMwpjPrAUjmxb7Z1gkkLsKoHf1iImSXvLIitz4pQ"}'
data = json.loads(response)
token = data['token']
print(token)
```
运行以上代码将会输出 `eyJhbGciOiJIUzUxMiJ9.eyJjbGFpbV9rZXkiOjE2ODY1NDA1NDIyNDUsInVzZXJJZCI6MSwic3ViIjoiYWRtaW4iLCJpYXQiOjE2ODY1NDA1NDIsImV4cCI6MTY4NjU0Nzc0Mn0.hSkWAezgpjEg1vHV8kfXskOVisjIVlVCT9hLXaaiT_zyLsVMwpjPrAUjmxb7Z1gkkLsKoHf1iImSXvLIitz4pQ`,即为所需的 token 值。
阅读全文