def get_score_in(low, high):
sql_conn = sqlite3.connect(db_file)
sql_cursor = sql_conn.cursor()
try:
sql_cursor.execute('select name, score from user where score between ? and ?', (low, high))
data = sorted(sql_cursor.fetchall(), key=lambda x: x[1])
return [ name[0] for name in data ]
finally:
sql_cursor.close()
sql_conn.close()
大晨紫Zzz
这里可以用SQL直接排序,或者用Python来进行排序。 提供一个Python的排序方式