Я хочу перенести пол строчки на другую строчку, чтобы текст вмещался. Как мне это исполнить?

Код:

@bot.command()
async def drake(ctx, *, text):
if len(text) > 45:
    return await ctx.send(embed=discord.Embed(title='Произошла ошибка!',         description=f'<:error:852403860765016097> {ctx.author.mention} ваш текст больше 45     символов!!',color=error))

text = text.split(";")
text2 = text[0]
text3 = text[1]
img = Image.open("drake.jpg")
draw = ImageDraw.Draw(img)
drawer = ImageDraw.Draw(img)
font = ImageFont.truetype("9303.ttf", 48)
drawer.text((355, 150), text=text2, fill='black',font=font)
draw.text((342, 470), text=text3,fill='black',font=font)
img.save("drake2.jpg")
img.paste(img, (7, 5))
await ctx.send(file = discord.File("drake2.jpg"))

Ответы (1 шт):

Автор решения: K_R_O_K_O_D_I_L_L_O

Для этого используется символ переноса строки: '\n'

Пример:

print('Hello' + '\n' + 'world!')

Вывод:

Hello
world!

Автоматизация:

import re

text = "Мой дядя самых честных правил Мой дядя самых честных правил"
text = re.split('[., ]+', text)
txt = ''

for i in range(len(text)):
    if (i/8).is_integer() and i/8!=0:
        txt = txt + '\n'
    txt = txt + ' ' + text[i]
print(txt)

Вывод:

 Мой дядя самых честных правил Мой дядя самых
 честных правил
→ Ссылка