TypeError:预期的str,字节或os.PathLike对象,而不是元组错误

时间:2019-05-07 04:09:40

标签: python-3.x tkinter

我正在获得预期的str,字节或os.PathLike对象,而不是元组错误。我无法将路径文件复制到变量。 我期望将路径复制到变量中

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div id="show" class="button-show">
  <button>show</button>
</div>

<div id="before-show" class="box">
  <div class="hello">
    <button id="hide">hide</button>
  </div>
</div>

以下是我遇到的错误

import os
import re
import ctypes
import tkinter as tk
from tkinter import Button,X
from tkinter.messagebox import askyesno,showwarning,showinfo
from tkinter.filedialog import askopenfilename,asksaveasfilename

root = tk.Tk ()

inname = ()
def btn1():
    global inname
    inname = askopenfilename(initialdir = "/",title = "Select file",filetypes = [("Text files","*.txt"),("all files","*.*")])
    print (inname)

errmsg = 'Error!'
outname = ()

def btn2():
    global outname
    outname = asksaveasfilename(initialdir = "/",title = "Select save",filetypes = (("Text files","*.txt"),("all files","*.*")))
    print(outname)

errmsg = 'Error!'

def btn3():
    if askyesno('Verify', 'Really quit?'):
        showwarning('Yes', command= root.destroy())
    else:
        showinfo('No', 'Quit has been cancelled')

errmsg  = 'Error!'

def btn4():
    showinfo('Help','contact admin')

errmsg = 'Error!'

Button(text='Open file', command=btn1).pack(fill=X)
Button(text='Save file', command=btn2).pack(fill=X)
Button(text='Quit', command=btn3).pack(fill=X)
Button(text='Help', command=btn4).pack(fill=X)

win= open(inname)
out = open(outname, "w+")

win.close()
out.close()
root.mainloop()
ctypes.windll.user32.MessageBoxA(0, "Job done", "job done", 1)

0 个答案:

没有答案