Askopenfile() 获得参数“模式”的多个值;在Python中
我正在用 python 编写一个 python 程序,它要求我使用打开的对话框,
但我收到以下错误
Askopenfile() 获得了参数“模式”的多个值
我的代码
def open_file():
browse_text.set("loading...")
file = askopenfile(root, mode='r', title="Choose a file", filetype=[("pdf file", "*.pdf")])
if file:
read_file = PyPDF2.PdfFileReader(file)
page = read_file.getPage(0)
page_content = page.extractText()
text_box = tk.Tex(root, height=10, width=50, padx=15, pady=15)
text_box.insert(1.0, page_content)
text_box.grid(column=1, row=3)
browse_text = tk.StringVar();
browse_btn = tk.Button(root, textvariable=browse_text, command=lambda: open_file(), bg="blue", fg="white", font="arial", height=3, width=15)
browse_text.set("Open file")
I am writing a python program in python which require that I use open Dialog
but I am getting the following error
askopenfile() got multiple values for argument 'mode'
My code
def open_file():
browse_text.set("loading...")
file = askopenfile(root, mode='r', title="Choose a file", filetype=[("pdf file", "*.pdf")])
if file:
read_file = PyPDF2.PdfFileReader(file)
page = read_file.getPage(0)
page_content = page.extractText()
text_box = tk.Tex(root, height=10, width=50, padx=15, pady=15)
text_box.insert(1.0, page_content)
text_box.grid(column=1, row=3)
browse_text = tk.StringVar();
browse_btn = tk.Button(root, textvariable=browse_text, command=lambda: open_file(), bg="blue", fg="white", font="arial", height=3, width=15)
browse_text.set("Open file")
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
askopenfile
不接受根
参数。所以只需更改
为
askopenfile
does not accept aroot
parameter.So just change
to