我已经尝试过多次查找此解决方案,但是它们都不起作用。试图制作一个使用 JSON 存储系统的不和谐机器人。该机器人是用python制作的。我将展示我尝试了多种方法来显示来自 JSON 存储的图像的代码。甚至 Utf-8 和 16 编码也不起作用。所以我现在一直在随机尝试任何事情。是这样的->
{
"id": 1,
"Name": "bulbasaur",
"Image": "https://i.imgur.com/MOQHxZGg.png"
}
JSON above
Python below
@commands.command(name='image_test')
async def image(self, context, arg):
with open('image.json') as image:
p = json.load(image)
p['Name'] = arg
#print(p['Name'])
#print(p['Image'])
#with urllib2.urlopen(p['Image']) as i:
#data = i.read().decode('ISO-8859-1')
embed = discord.Embed()
embed.title = 'test image'
embed.set_image(url=requests.get(p['Image']).url)
await context.channel.send(embed=embed)