代码以及效果如下
import numpy as np
import random
import PIL.Image as image
import PIL.ImageDraw as draw
import PIL.ImageFont as imgfont
import PIL.ImageFilter as ifr
font = imgfont.truetype("C:/Windows/Fonts/CHARLEMAGNESTD-BOLD.OTF",60)#导入字体路径以及大小
w=240
h=9