Discuss / Python / 请编写函数,在Sqlite中根据分数段查找指定的名字

请编写函数,在Sqlite中根据分数段查找指定的名字

Topic source

joffery_zp

#1 Created at ... [Delete] [Delete and Lock User]
def get_score_in(low, high):
    #返回指定分数区间的名字,按分数从低到高排序
    try:
        con=sqlite3.connect(db_file)
        cursor=con.cursor()
        cursor.execute("select name from user where score between {} and {} order by score".format(low,high))
        values = cursor.fetchall()
    except Exception as e:print(e)
    finally:
        cursor.close()
        conn.close()
    return [i[0] for i in values]

  • 1

Reply