可以使用Python的sorted函数并结合lambda函数来实现不区分大小写的比较。示例代码如下:
list1 = ['apple', 'Pineapple', 'orange', 'banana'] list2 = ['Apple', 'pineapple', 'ORANGE', 'BaNaNa']
sorted_list1 = sorted(list1, key=lambda x: x.lower()) sorted_list2 = sorted(list2, key=lambda x: x.lower())
if sorted_list1 == sorted_list2: print("The two lists are equal.") else: print("The two lists are not equal.")
输出结果为:The two lists are equal.
下一篇:不区分大小写的包含条件:震动转换