def change():
wind = Tk()...
text1 = Entry(wind)
text1.pack()
def write():
newfile = open("newfile.txt", "w")
newfile.write(text1.get())
newfile.close()
def show_password():
global r1
r1 = open("newfile.txt", "r")
print("Password is: %s" % r1.read())
btn2 = Button(wind, text="Show Password", command=show_password)
btn2.pack(pady=5)
btn1 = Button(wind, text="Set Password", command=write)
btn1.pack(pady=5)
def dark():
pop = Tk()...
e1 = Entry(pop, background="#292929", foreground="white")
e1.place(x=60, y=0)
e2 = Entry(pop, background="#292929", foreground="white")
e2.place(x=60, y=22)
def login():
global no1
username = (e1.get())
password = (e2.get())
print("Username: %s\nPassword: %s" % (e1.get(), e2.get()))
if username == "a" and password == r1.read():
new_win = Tk()...
elif username == "a" and password != r1.read():
sleep(5)
mainloop()
每當我運行程式時,我都不會收到錯誤訊息。但是,當我輸入剛剛設定或設定的密碼(在 txt 檔案中)或終端中列印的內容時,它會使程式休眠,就像我弄錯了一樣。之前發過,太長了,現在刪了。這只是對我的評估的修訂。
uj5u.com熱心網友回復:
例如你可以這樣做:
File = open(‘file.txt’, ‘r’)
File_context = File.read()
File.close()
If ‘Word’ in File_context:
Print(‘FOUND!’)
告訴我它是否有效!
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/323791.html
標籤:Python 特金特 python-3.9 文本
上一篇:Tkinteraskdirectory()未顯示在螢屏上
下一篇:無法向框架添加小部件
