def get_score_in(low, high):
conng = sqlite3.connect('test.db')
cursorg = conng.cursor()
cursorg.execute(' select name from user where score >= ' + str(low) + ' and score<= '+str(high) + ' order by score')
values = cursorg.fetchall()
cursorg.close()
conng.close()
return [name[0] for name in values]
Reva龙舞
def get_score_in(low, high): conng = sqlite3.connect('test.db') cursorg = conng.cursor() cursorg.execute(' select name from user where score >= ' + str(low) + ' and score<= '+str(high) + ' order by score') values = cursorg.fetchall() cursorg.close() conng.close() return [name[0] for name in values]
看了下其他人的,确实占位符的方式比直接拼接字符串更加优雅