Discuss / Python / work

4Neutrino

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

def get_score_in(low, high): ' 返回指定分数区间的名字,按分数从低到高排序 ' conn = sqlite3.connect(db_file) cursor = conn.cursor() cursor.execute(r"select name from user where score between ? and ? order by score", (low, high)) rows = cursor.fetchall() cursor.close() conn.commit() conn.close()

return list(map(lambda x: x[0], rows))

4Neutrino

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

def get_score_in(low, high): ' 返回指定分数区间的名字,按分数从低到高排序 ' with sqlite3.connect(db_file) as conn: cursor = conn.cursor() cursor.execute(r"select name from user where score between ? and ? order by score", (low, high)) rows = cursor.fetchall() cursor.close() conn.commit()

return [r[0] for r in rows]

  • 1

Reply