Discuss / Python / 练习

练习

Topic source
def get_score_in(low, high):
    ' 返回指定分数区间的名字,按分数从低到高排序 '
    conn=sqlite3.connect(db_file)
    cursor=conn.cursor()
    cursor.execute('select name from user where score>='+str(low)+' and score<='+str(high)+'  order by score asc')
    values=cursor.fetchall()
    cursor.close()
    conn.close()
    result=[]
    for v in values:
        result.append(v[0])
    return result

  • 1

Reply