要忽略大小写,可以先使用将两个字符统一转化为大写,然后再作比较,如下:s1="hello"s2="hello"ifs1.upper()==s2.upper():print"两个字符串相同"#输出结果为:两个字符串相同
s1 = 'abc's2 = 'Abc'if s1.lower == s2.lower(): print('ok')