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
    拼写错误

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

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

报告相同问题?

悬赏问题

  • ¥30 Matlab打开默认名称带有/的光谱数据
  • ¥50 easyExcel模板 动态单元格合并列
  • ¥15 res.rows如何取值使用
  • ¥15 在odoo17开发环境中,怎么实现库存管理系统,或独立模块设计与AGV小车对接?开发方面应如何设计和开发?请详细解释MES或WMS在与AGV小车对接时需完成的设计和开发
  • ¥15 CSP算法实现EEG特征提取,哪一步错了?
  • ¥15 游戏盾如何溯源服务器真实ip?需要30个字。后面的字是凑数的
  • ¥15 vue3前端取消收藏的不会引用collectId
  • ¥15 delphi7 HMAC_SHA256方式加密
  • ¥15 关于#qt#的问题:我想实现qcustomplot完成坐标轴
  • ¥15 下列c语言代码为何输出了多余的空格