用python 比较两个strings 是否相同,忽略大小写程序怎么写

2025-03-26 20:44:06
推荐回答(2个)
回答1:

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

回答2:

s1 = 'abc'
s2 = 'Abc'

if s1.lower == s2.lower():
    print('ok')