Discuss / Python / code

船长杰克

#1 Created at ... [Delete] [Delete and Lock User]

def get_score_in(low, high):
    ' 返回指定分数区间的名字,按分数从低到高排序 '
    try:
        conn = sqlite3.connect(db_file)
        cursor = conn.cursor()
        cursor.execute('select name from user where score > %s AND score <= %s ORDER BY score' % (low,high))
        datas = cursor.fetchall()
        print(datas)
    finally:
        cursor.close()
        conn.close()
    return [x[0] for x in datas]

LvZhe618

#2 Created at ... [Delete] [Delete and Lock User]

直接在SQL中排好序吗?厉害。


  • 1

Reply