标签:添加 htm button 思路 col gif 制作 man 翻译
1 import requests 2 from tkinter import * 3 from PIL import Image,ImageTk 4 def get_ewm(): 5 url = ‘http://www.wwei.cn/qrcode-wwei_create.html‘ 6 strs = entry.get() 7 dat = { 8 ‘data[text]‘:strs, 9 ‘data[type]‘:‘index‘, 10 ‘level‘:‘L‘,#容错率 LMQH 11 ‘moban_id‘:0, 12 ‘qrid‘:0, 13 ‘size‘:555,#图像大小,单位px 14 ‘style_setting[bcolor]‘:‘# ffffff‘, 15 ‘style_setting[fcolor]‘ : ‘# 000000‘, 16 ‘style_setting[inptcolor]‘: ‘# 000000‘, 17 ‘style_setting[logo_border]‘: 0, 18 ‘style_setting[logo_height]‘:46, 19 ‘style_setting[logo_id]‘:‘‘, 20 ‘style_setting[logo_width]‘:46, 21 ‘style_setting[mbtype_hb]‘:0, 22 ‘style_setting[protype]‘:2,#圆点、直角、液态 0\1\2 23 ‘style_setting[ptcolor]‘:‘# 000000‘} 24 html = requests.post(url,data=dat).json() 25 img_url = html[‘png_url‘] 26 with open(‘123.png‘,‘wb‘) as f: 27 f.write(requests.get(img_url).content) 28 load = Image.open(‘123.png‘) 29 im1 = ImageTk.PhotoImage(load) 30 label = Label(tk, image=im1,compound = ‘bottom‘) 31 label.image = im1 32 label.grid(row=2,columnspan=6) 33 if __name__ == ‘__main__‘: 34 tk = Tk() 35 tk.title(‘二维码生成器‘) 36 tk.geometry(‘640x600+200+20‘) 37 entry = Entry(tk, font=(‘微软雅黑‘),width=60) # 创建输入框 38 entry.grid(row=1, column=4) # 定位第1行3列 39 str_b = Button(tk,text=‘生成二维码‘,command=get_ewm) 40 str_b.grid(row=1,column=5) 41 tk.mainloop()
python有哪些好玩的应用实现,用python爬虫做一个二维码生成器
标签:添加 htm button 思路 col gif 制作 man 翻译
原文地址:https://www.cnblogs.com/qun542110741/p/9346079.html