API错误:TypeError:字符串索引必须是整数
我真的是Stackoverflow的新手。
我想创建一个 pterodactyl 使用Python的客户端面板。但是,如果我想在面板上获取服务器信息,它将向我展示:
Traceback (most recent call last):
File "system_server.py", line 16, in <module>
print(resp['data'])
TypeError: string indices must be integers
我的代码:
import json
import requests
import configuration
url = 'https://client.blutudlut.xyz/api/application/servers'
headers = {
"Authorization": "Bearer "+ configuration.pterodactyl_admin_api,
"Accept": "application/json",
"Content-Type": "application/json",
}
response = requests.request('GET', url, headers=headers)
print(response.text)
json_str = json.dumps(response.text)
resp = json.loads(json_str)
print(resp)
print(resp['data'])
我尝试了多种方法,但始终是同一问题。
I'm really new to StackOverflow.
I want to create a Pterodactyl Client Panel using Python. But if I want to get the servers Info on the Panel it shows me this:
Traceback (most recent call last):
File "system_server.py", line 16, in <module>
print(resp['data'])
TypeError: string indices must be integers
My Code:
import json
import requests
import configuration
url = 'https://client.blutudlut.xyz/api/application/servers'
headers = {
"Authorization": "Bearer "+ configuration.pterodactyl_admin_api,
"Accept": "application/json",
"Content-Type": "application/json",
}
response = requests.request('GET', url, headers=headers)
print(response.text)
json_str = json.dumps(response.text)
resp = json.loads(json_str)
print(resp)
print(resp['data'])
I tried many ways but it's always the same problem.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论