【发布时间】:2020-11-04 20:25:19
【问题描述】:
我学习了 python,我做了一个不和谐的机器人。在“anivia”之后打印元素有一些困难。我不能说'texte'中是否有“anivia”,我可以数他,但我不知道如何在“anivia”之后打印元素,如果有人可以帮助我请:)
@bot.command()
async def counter(ctx, *champion):
champion = " ".join(champion)
url = "https://u.gg/lol/champions/"
counter = "/counter"
uurl = url + champion + counter
await ctx.send(uurl)
import urllib.request
with urllib.request.urlopen(uurl) as response:
texte = response.read()
if ("anivia" in str(texte)):
print("Le mot existe !")
else:
print("Le mot n'existe pas!")
test = str(texte)
z = test.count('anivia')
print(z)
我可以用 z 数 9 个“anivia”,我想在所有 anivia 之后打印下一个元素(例如:“你好,我是 anivia,我喜欢 anivia 测试”:and, 测试)。
感谢您的帮助:)
【问题讨论】:
标签: python python-3.x discord