我有一个python脚本,使用PIL将文本写入图像.这一切都很好,除非我遇到带有回车符的字符串.我需要在文本中保留回车符.而不是将回车写入图像,我得到一个小盒子字符,返回应该是.以下是编写文本的代码:
<code>
draw = ImageDraw.Draw(blankTemplate)
draw.text((35 + attSpacing, 570),str(attText),fill=0,font=attFont)
</code>
Run Code Online (Sandbox Code Playgroud)
attText是我遇到麻烦的变量.我在写它之前将它转换为字符串,因为在某些情况下它是一个数字.
谢谢你的帮助.