def get_valid_img(request): # 方式2:基于PIL模块创建验证码图片 from PIL import Image, ImageDraw, ImageFont from io import BytesIO def get_random_color(): import random return (random.randint(0, 255), random.randint(0, 255), random.randint(0, 255)) # img=Image.new(…