我先用in来做一次
def find_text(text_input1, text_input2):
a = str(text_input1)
b = str(text_input2)
if b in a:
print(f"The {b} is in {a} ")
else:
print(f"The {b} is not in {a} ")
text_n1 = "Welcome to shenyang"
text_n2 = "to"
find_text(text_n1, text_n2)
使用find
def find_text(text_input1, text_input2):
a = str(text_input1)
b = str(text_input2)
if a.find(b) != -1:
print(f"The {b} is in {a} ")
else:
print(f"The {b} is not in {a} ")
text_n1 = "Welcome to shenyang"
text_n2 = "to"
find_text(text_n1, text_n2)