0

i have made that when ever someone reg the txt file is created and named on user username. now im trying to check if username txt file is there in dir or not here is the code i tried . im unable to check if username txt file is there . i tried many diff way searched google but no luck some i have mentioned as comment. pls help looking

 def db():
        a = (E1.get(), E2.get(), E3.get(),E4.get(),E5.get())
        
        if "./library/"+E1.get() == os.path.isfile("./library/"+E1.get()):
        # if E1.get() == os.path.isfile(E1.get()):
        # if E1.get()in os.path.isdir("./library/"):

            cur.execute("insert into Booking values(?,?,?,?,?)", a)
            con.commit()
            cur.execute("select * from Booking")
            a = cur.fetchall()
            ab = int(E4.get())
            cost=100
            ac = ab * cost
            messagebox.showinfo("Congratulation!!", "Your oreder value is %s" % ac)
            print(a)

            te.destroy()
            os.system("library.py")
        else:
            print("username invalid")
anshul raj
  • 125
  • 9

1 Answers1

2

Try replacing the below line

if "./library/"+E1.get() == os.path.isfile("./library/"+E1.get()):

with

if os.path.isfile("./library/"+E1.get()):

You probably are confused with the return value of os.path.isfile() fn.

P S Solanki
  • 1,033
  • 2
  • 11
  • 26