Python のリストは完全に等価ピットです。要素の順序が異なると不等であると判断されます。

list1 = ["one","two","three"]
list2 = ["one","two","three"]
print(list1 == list2) # True
list1 = ["one","three","two"]
list2 = ["one","two","three"]
print(list1 == list2) # False 

解決

list1 = ["one","two","three"]
list2 = ["one","three","two"]
list1.sort()
list2.sort() # 改变list本身
print(list1 == list2)
list1 = ["one","two","three"]
list2 = ["one","three","two"]
list1 = sorted(list1)
list2 = sorted(list2) # 不改变list本身
print(list1 == list2)

おすすめ

転載: blog.csdn.net/weixin_41951954/article/details/130005698