[英]'str' object has no attribute 'text'. Cant seem to be able to fix it
Can someone please help me with this error, ive looked at other ones that had the same error but cant seem to apply it to my code, i dont know if that is because im just bad at coding or that it is because it cant be applied to my code, i would prefer people to send the updated code then that they send me what to do in words cause i normally dont understand it有人可以帮我解决这个错误吗,我查看了其他有相同错误但似乎无法将其应用于我的代码的错误,我不知道这是因为我只是不擅长编码还是因为它无法应用对于我的代码,我希望人们发送更新后的代码,然后他们将用文字发送给我,因为我通常不明白
This is my code:这是我的代码:
@client.command()
async def ipcheck(ctx, IP):
await ctx.send(get('https://ipapi.co/' + (IP) + '/json/').text)
This is the error:这是错误:
Ignoring exception in command ipcheck:
Traceback (most recent call last):
File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "C:\Users\User\Desktop\Programming\TEST.py", line 51, in ipcheck
await ctx.send(get('https://ipapi.co/' + (IP) + '/json/').text)
AttributeError: 'str' object has no attribute 'text'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'str' object has no attribute 'text'
It seems that get('https://ipapi.co/' + (IP) + '/json/')
already returns a string, there's no need for you to use the text
attribute看来
get('https://ipapi.co/' + (IP) + '/json/')
已经返回了一个字符串,你不需要使用text
属性
@client.command()
async def ipcheck(ctx, IP):
await ctx.send(get('https://ipapi.co/' + (IP) + '/json/'))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.