【问题标题】:while replacing the input string spaces with underscore and then checking it it does not replaces在用下划线替换输入字符串空格然后检查它时它不会替换
【发布时间】:2022-11-04 23:29:02
【问题描述】:
                game=input("enter student name to update report card: ")
                nn=game.replace("  ", "_")
                mycursor.execute("show tables")
                klm = mycursor.fetchall()
                if (nn,) in klm:
                    b=int(input("enter sno: "))
                    mycursor.execute("select * from {} where sno='{}'".format(nn,b))
                    xer=mycursor.fetchall()
                        
                else:
                    print("no student record found")

这不执行

if 语句直接转到

否则即使我有

表名 some_one

表明

没有找到记录

【问题讨论】:

    标签: python mysql python-3.x replace


    【解决方案1】:

    您正在搜索元组 (nn,) 是您的任何表名。试试这个:

    if nn in klm:
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-07-12
      • 2015-07-06
      • 2020-02-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多