有没有办法比较字符串,以便将大写和小写字母视为同一个字母?
例如,/* 1 */
{
"_id" : ObjectId("58b179a730c6c0da2c31a4de"),
"field1" : 321.0,
"field2" : "12",
"RegNo" : "1122",
"State" : "AZ",
"Car" : "camry"
}
/* 2 */
{
"_id" : ObjectId("58b179a730c6c0da2c31a4df"),
"field1" : 321.0,
"field2" : "13",
"RegNo" : "1123",
"State" : "AZ",
"Car" : "camry"
}
/* 3 */
{
"_id" : ObjectId("58b179a730c6c0da2c31a4e0"),
"field1" : 323.0,
"field2" : "12",
"RegNo" : "1124",
"State" : "CA",
"Car" : "accord"
}
会产生'ABC' == 'abc
答案 0 :(得分:1)
简单的解决方案是将两个值都转换为大写或大写,并在相等时进行比较。
string1, string2 = "ABC", "abc"
string1.lower() == string2.lower()