【发布时间】:2021-12-24 20:54:01
【问题描述】:
这是我的代码:
import qrcode
from tkinter import *
from tkinter import filedialog
root=Tk()
def choosefile():
global file
file=filedialog.askopenfile(mode='r',title='Choose a File')
choosefilebutton=Button(root,text='Choose a File',command=choosefile)
choosefilebutton.pack()
def submit():
qr=qrcode.make(file)
qr.save('qrcode.png')
choosefilebutton=Button(root,text='Submit',command=submit)
choosefilebutton.pack()
root.mainloop()
它制作了一个二维码,但是当我扫描二维码时,结果是:
<_io.TextIOWrapper name='/Users/charliezhang/Desktop/hello.png' mode='r' encoding='UTF-8'>
我是 Python 新手,还不太了解所有内容 有人可以帮忙吗?
【问题讨论】:
-
您实际上从未在文件上调用
.read()来获取其内容;你用文件对象本身制作了你的二维码。
标签: python tkinter python-imaging-library qr-code