Skip to main content
 首页 » 编程设计

Python 字符串函数

2025年05月04日1498°冷暖

希望组合一个简单的 python 函数来检查以下内容

给定两个字符串,如果其中一个字符串出现在另一个字符串的末尾,则返回 True, 忽略大写/小写差异(换句话说,计算不应该是“大小写 敏感”)。

end_other('Hiabc', 'abc') → True 
end_other('AbC', 'HiaBc') → True 
end_other('abc', 'abXabc') → True 

请您参考如下方法:

尝试

def end_other(s1, s2): 
    s1 = s1.lower() 
    s2 = s2.lower() 
    return s1.endswith(s2) or s2.endswith(s1)