作者gogogo123 (狗狗睾丸被割)
看板Python
标题[问题] entry输入的数值资料库抓不到???
时间Fri Dec 13 17:06:00 2019
这里原本是做快速制作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://webptt.com/cn.aspx?n=bbs/Python/M.1576227965.A.4BC.html
※ 编辑: gogogo123 (117.56.227.246 台湾), 12/13/2019 17:11:15
1F:→ kobe8112: 把name印出来 12/13 17:40