【发布时间】:2019-02-05 17:10:38
【问题描述】:
request = requests.get("http://api.roblox.com/Marketplace/ProductInfo?assetId=1834225941").content
print(str(request["Sales"]))
这会产生以下错误:
Traceback (most recent call last):
File "C:\Users\yorks\Desktop\BloxUtility\bot.py", line 22, in <module>
print(int(request["Sales"]))
TypeError: byte indices must be integers or slices, not str
你能帮帮我吗?
【问题讨论】:
-
您的示例和错误消息中的代码不合适(
int()与str()转换)-请澄清! -
"byte indices must be integers or slices, not str" 表示你做了
a_bytes_object[a_str_object],其中只有a_bytes_object[an_int_object],而你的代码有request["Sales"],所以很明显@ 987654328@是bytes对象,也就是说不支持["Sales"]。
标签: python