题解 | #字符串通配符#

字符串通配符

https://www.nowcoder.com/practice/43072d50a6eb44d2a6c816a283b02036

def func(s1, s2):
    if s2 == "":
        if s1.replace("*", "") == "":
            return True
        else:
            return False
    if s1 == "" and s2 != "":
        return False
    if s1[-1] == s2[-1] or (s1[-1] == "?" and s2[-1].isalnum()):
        return func(s1[:-1], s2[:-1])
    elif s1[-1] == "*":
        return func(s1[:-1], s2) or func(s1, s2[:-1])
    elif s1[-1]!=s2[-1]:
        return False


s1 = input().lower()
s2 = input().lower()
if func(s1, s2):
    print("true")
else:
    print("false")

全部评论

相关推荐

熬夜冠军🏆:和你情况差不多,你这个HR算敞亮了,直白告诉你了,不浪费你时间,我的那个还跟我说没法说,只能等。
点赞 评论 收藏
分享
程序员小白条:这比例牛逼,750:1
点赞 评论 收藏
分享
07-23 18:25
河北大学 Java
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务