九州体育网 - 十年信誉网站

关于作者

Discuss / Python / 这个list没法相等啊

这个list没法相等啊

Topic source

舞雨口口窘

#1 Created at ...

代码如下

def get_score_in(low, high): con=sqlite3.connect(db_file) cursor=con.cursor() cursor.execute('select * from user where score>=? and score<=?',(low,high)) results=[x[1] for x in cursor.fetchall()] print(results) cursor.close() con.close() return results 这是运行结果 ['Adam'] ['Bart', 'Lisa'] ['Adam', 'Bart', 'Lisa'] ['Adam', 'Bart', 'Lisa'] 最后一个assert抛出了错误,原因是['Adam', 'Bart', 'Lisa']!=['Bart', 'Lisa', 'Adam'],现在才发现[1,2]!=[2,1]

__回头青春都喂了狗

#2 Created at ...

list是有顺序的set是无序的


  • 1

Reply

WARNING: You are using an old browser that does not support HTML5. Please choose a modern browser (Chrome / Microsoft Edge / Firefox / Sarafi) to get a good experience.