Prt_sc_End 2020-06-17 21:19 采纳率: 75%
浏览 137
已采纳

Python大佬们帮我看看

图片说明
报错:name 'falg' is not defined
import sqlite3
def opendb():
conn = sqlite3.connect("d:\mydb.db")
cue = conn.execute("""create table if not exists tongxunlu(usernum onteger primary kry,user name varchar(128),password varchar(128),address varcher(125),telnum varchar(128))""")
return cur,conn
def showalldb():
print("处理后的数据")
hel = opendb()
cur = hel[1].cursor()
cur.rxrcute("select * from tongxunlu")
res = cur.fetchall()
for lin in res:
for h in line:
print(h),
print
cur.close()
def into():
usernum = input("请输入学号")
username1 = input("请输入姓名")
password1 = input("请输入密码")
return usernum,username1,password1
def adddb():
welcome = """欢迎使用添加数据功能"""
print(welcome)
person = into()
hel = opendb()
hel[1].execute("insert into tongxunlu(usernum,username,password)values(?,?,?)",(person[0],person[1],person[2]))
hel[1].commit()
print("恭喜,添加数据成功")
showalldb()
hel[1].close()
def deldb():
welcome = "欢迎使用删除功能"
print(welcome)
delchoice = input("请输入想删除的学号")
hel = opendb()
hel[1].execute("delete from tongxunlu where username ="+delchoice)
hel[1].commit()
print("删除成功")
showalldb()
hel[1].close()
def alter():
welcome = "欢迎使用修改功能"
print(welcome)
changechoice = input("请输入学号")
hel = opendb()
person = into()
hel[1].execute("update tongxunlu set usernum = ?,username = ?,password = ? where usernum = "+ changechoice,(person[0],person[1],person[2]))
hel[1].commit()
showalldb()
hel[1].close()
def searchdb():
welcome = "欢迎使用查询功能"
print(welcome)
choice = input("请输入学号")
hel = opendb()
cur = hel[1].cursor()
cur.execute("select * from tongxunlu where usernum = "+ choice)
hel[1].commit()
print("数据如下")
for row in cur:
print(row[0],roe[1],row[2])
cur.close()
hel[1].close()
def conti(a):
choice = input("是否继续")
if choice == 'y':
a = 1
else:
a = 0
return a
if __name_ == "__main__":
flag = 1
while falg:
_
welcome = "欢迎使用数据库"
print(welcome)
choiceshow = """
请选择:
(添加)添加
(删除)删除
(修改)修改
(查询)查询
选择您的操作:
"""
choice = input(choiceshow)
if choice =="添加":
adddb()
conti(flag)
elif choice =="删除":
deldb()
conti(flag)
elif choice =="修改":
alter()
conti(flag)
elif choice =="查询":
searchdb()
conti(flag)
else:
print("输入错误")
print("请重新出入")

  • 写回答

1条回答 默认 最新

  • threenewbee 2020-06-17 23:40
    关注

    前面是fkag
    后面写成了 falg
    拼写错误

    问题解决的话,清点下采纳

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 oracle集群安装出bug
  • ¥15 关于#python#的问题:自动化测试
  • ¥20 问题请教!vue项目关于Nginx配置nonce安全策略的问题
  • ¥15 教务系统账号被盗号如何追溯设备
  • ¥20 delta降尺度方法,未来数据怎么降尺度
  • ¥15 c# 使用NPOI快速将datatable数据导入excel中指定sheet,要求快速高效
  • ¥15 再不同版本的系统上,TCP传输速度不一致
  • ¥15 高德地图2.0 版本点聚合中Marker的位置无法实时更新,如何解决呢?
  • ¥15 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题