您可以
textwrap.wrap用来分解
text成字符串列表,每个字符串最多为
width字符:
import textwraplines = textwrap.wrap(text, width=40)y_text = hfor line in lines: width, height = font.getsize(line) draw.text(((w - width) / 2, y_text), line, font=font, fill=FOREGROUND) y_text += height



