以下代码是Python中不区分大小写的字符串比较的示例。
string1 = 'Star Wars' string2 = 'star wars' if string1.lower() == string2.lower(): print "The strings are case insensitive" else: print "The strings are not case insensitive"
输出结果
此代码提供以下输出
The strings are case insensitive