Python Programming Quick Start 15th Chapter Practical Project Reference Answer (17.7.3)

Source: Internet
Author: User

#! Python3#Encoding:utf-8ImportOs,docx fromPILImportImage, Imagedraw fromPILImportImagefontos.chdir ('C:\\users\\administrator\\python35-32\\test\\kuaisu') Guests= Open ('Guests.txt') Logoim= Image.open ('flowerlogo.jpg') width, height=Logoim.sizelogoim= Logoim.resize ((166,108)) #重新定义LOGO大小 forIinchGuests:im= Image.new ('RGBA', (230, 362),' White') #生产白色卡片 Draw=Imagedraw.draw (IM) draw.rectangle ((1, 1, 228, outline=),'Black') #画黑色边框 N= (230-len (i) *12.5)/2 #计算开始位置 to center the guest nameft= Imagefont.truetype ("C:\\windows\\fonts\\brushsci. TTF", 13) Draw.text (13,30), U"It would is a pleasure to the", Font = ft, fill ='Blue') ft= Imagefont.truetype ("C:\\windows\\fonts\\engr. TTF", 15) Draw.text (n,I, Font = ft, fill ='Black') ft= Imagefont.truetype ("C:\\windows\\fonts\\brushsci. TTF", 15) Draw.text (19,130), U"At 11010 Memory Lane on the evening of", Font = ft, fill ='Blue') ft= Imagefont.truetype ("C:\\windows\\fonts\\calibri.ttf", 15) Draw.text (72,180), U"April 1st", Font = ft, fill ='Blue') ft= Imagefont.truetype ("C:\\windows\\fonts\\brushsci. TTF", 15) Draw.text (72,230), U"At 7 o ' clock", Font = ft, fill ='Blue') Im.paste (Logoim, (20, 252)) #加上LOGO name= STR ("Sitcard ("+ I.strip ('\ n') +"). png") #保存为客户名字 im.save (name)

Python Programming Quick Start 15th Chapter Practical Project Reference Answer (17.7.3)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.