response = get(url='https://benbotfn.tk/api/v1/aes')
data = response.json()
@client.command()
async def aes123(ctx):
await ctx.send(data['mainKey'])
@client.command()
async def aeskey(ctx):
embed=discord.Embed(title="aes")
embed.add_field(name='aes', value=f'{data['mainKey']} aes key')
await ctx.send(embed=embed)
I am getting this error when I run this code:
I really don't know what's wrong with this code and I'm just starting out, so sorry if this is a dumb question!
Inside f''
strings, if you need to access something using another string, its best to use the other quote type.
In this case:
value=f'{data['mainKey']} aes key'
is invalid syntax since you have sets of quotes within a string literal. The correct way to do it in this case is:
value=f'{data["mainKey"]} aes key'
Note the use of double quotes. Alternative options include:
value=f"{data['mainKey']} aes key"
value=f'''{data['mainKey']} aes key'''
value=f"""{data["mainKey"]} aes key"""
All of these options are valid and have their uses.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.