[問題] entry輸入的數值資料庫抓不到???
這裡原本是做快速製作bat檔
def menu():
os.system("cls")
print("IP查詢系統")
print("-------------------------")
print("5. 查詢個人 IP")
print("-------------------------")
def see_data():
while True:
name =input("請輸入姓名(Enter==>停止輸入)")
if name=="": break
sqlstr="select * from password where name='{}'" .format(name)
cursor=conn.execute(sqlstr)
row = cursor.fetchone()
#print(row)
if row==None:
print("{} 帳號不存在!".format(name))
continue
print("你的ip為:{}".format(row[1]))
content=str('netsh interface ip set address "區域連線" static')+"
"+(row[1])+'\nnetsh interface ip set dns "區域連線" static 210.69.1.1'
f = open('test.bat','w+')
f.write(content)
f.close()
### 主程式從這裡開始 ###
import os,sqlite3
conn = sqlite3.connect('Sqlite01.sqlite')
while True:
menu()
choice = int(input("請輸入您的選擇:"))
print()
if choice==5:
see_data()
conn.close()
print("程式執行完畢!")
以上在執行沒問題 也可以產生BAT檔 但我想弄成圖形化 就出現問題了
def see_data():
global ipname
while True:
name =ipname
if name=="": break
sqlstr="select * from password where name='{}'" .format(name)
cursor=conn.execute(sqlstr)
row = cursor.fetchone()
#print(row)
if row==None:
print("{} 帳號不存在!".format(name))
continue
print("你的ip為:{}".format(row[1]))
content=str('netsh interface ip set address "區域連線" static')+"
"+(row[1])+'\nnetsh interface ip set dns "區域連線" static 210.69.1.1'
f = open('test.bat','w+')
f.write(content)
f.close()
### 主程式從這裡開始 ###
import os,sqlite3
import tkinter as tk
conn = sqlite3.connect('Sqlite01.sqlite')
win=tk.Tk()
win.geometry("560x280") #設定主視窗解析度
win.title("製作ip.bat檔")
ipname = tk.StringVar()
label1=tk.Label(win, text="您的大名:")
label1.place(x=123, y=30)
entryUrl = tk.Entry(win, textvariable=ipname)
entryUrl.config(width=45)
entryUrl.place(x=220, y=30)
btnDown = tk.Button(win, text="製作bat檔", command=see_data)
btnDown.place(x=200, y=110)
win.mainloop()
就會出現帳號不存在
很奇怪 用Entry 輸入的值 跳到函式後反而找不到呢
抓不到資料庫的資料 很奇怪 請各位大大解答
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 117.56.227.246 (臺灣)
※ 文章網址: https://www.ptt.cc/bbs/Python/M.1576227965.A.4BC.html
※ 編輯: gogogo123 (117.56.227.246 臺灣), 12/13/2019 17:11:15
→
12/13 17:40,
5年前
, 1F
12/13 17:40, 1F
Python 近期熱門文章
PTT數位生活區 即時熱門文章