def get_score_in(low, high): ' 返回指定分数区间的名字,按分数从低到高排序 ' values = [] try: conn = sqlite3.connect('db_file.db') cursor = conn.cursor() #执行查询语句 cursor.execute('select name from user where score between ? and ?',(low, high)) values = cursor.fetchall() finally: cursor.close() conn.close() if len(values) == 0: print('查询记录失败,没有这个分数段的学生!!!') return return values, 'get_score_in(%s,%s)' % (low, high) print(get_score_in(90, 100))
Sign in to make a reply
王新美男