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 AIC3204的示例代码有吗,想用AIC3204测量血氧,找不到相关的代码。
  • ¥20 CST怎么把天线放在座椅环境中并仿真
  • ¥15 任务A:大数据平台搭建(容器环境)怎么做呢?
  • ¥15 YOLOv8obb获取边框坐标时报错AttributeError: 'NoneType' object has no attribute 'xywhr'
  • ¥15 r语言神经网络自变量重要性分析
  • ¥15 基于双目测规则物体尺寸
  • ¥15 wegame打不开英雄联盟
  • ¥15 公司的电脑,win10系统自带远程协助,访问家里个人电脑,提示出现内部错误,各种常规的设置都已经尝试,感觉公司对此功能进行了限制(我们是集团公司)
  • ¥15 救!ENVI5.6深度学习初始化模型报错怎么办?
  • ¥30 eclipse开启服务后,网页无法打开