题解 | #字符串通配符#
字符串通配符
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")