def get_score_in(low, high):
' 返回指定分数区间的名字,按分数从低到高排序 '
conn = sqlite3.connect(db_file)
cur = conn.cursor()
try:
cur.execute('select * from user where score between ? and ? order by score',(low,high))
data = cur.fetchall()
print(data)
data = sorted(data, key=lambda s: s[2]) # [('id','name','score'),(),()...], 根据score排序
print(data)
return list(map(lambda x : x[1], data))
finally:
cur.close()
conn.close()
用户5307799436