Discuss / Python / 交作业:

交作业:

Topic source
def get_score_in(low, high):
    ' 返回指定分数区间的名字,按分数从低到高排序 '   
    try:
        conn = sqlite3.connect(db_file)
        cursor = conn.cursor()
        cursor.execute('select * from user where score > ? and score <= ?', (low, high))
        l = sorted(cursor.fetchall(), key=lambda x: x[2], reverse=False)
    finally:
        cursor.close()
        conn.close()
    return list(n[1] for n in l)

  • 1

Reply