#-*-coding:utf-8-*-" "Title Description: Using Python to generate similar letters in the Code picture idea: using the PIL Library and random letters to generate" "ImportRandomImportstring fromPILImportImage, Imagedraw, Imagefont, ImageFilterdefRnword ():returnRandom.choice (string.letters)defcolor ():return(Random.randint (255), Random.randint (255), Random.randint (64, 255))defColor2 ():return(Random.randint (127), Random.randint (127), Random.randint (32, 127))defDraw (width, height, n): bgcolor= (255, 2155, 255) Image= Image.new ('RGB', (width, height), bgcolor) font= Imagefont.truetype ('C:/windows/fonts/arial.ttf', 30) FontColor=(0, 0, 0) draw=Imagedraw.draw (image) forXinchRange (width): forYinchRange (height): Draw.point ((x, y), fill=color ()) forWinchrange (N): Draw.text ((* W + ten, Rnword (), Font=font, fill=Color2 ()) Image=Image.filter (Imagefilter.blur) Image.Save ('test3.jpg','JPEG')if __name__=='__main__': Draw (240, 60, 4)
Python Practice book A small program for the No. 0010 question every day