《python语言程序设计》2018版第8章第2题检查子串, 使用str类的find方法检查一个字符串是否是另一个字符串的子串

##代码一
def str_find():str1 = input("Enter no1 str: ")str2 = input("Enter no2 str: ")if str2 in str1:print("The str2 is in str1")else:print("The str2 is not in str1")str_find()

代码二
def str_find():str1 = input("Enter no1 str: ")str2 = input("Enter no2 str: ")if str1.find(str2) >= 0:print("The str2 is in str1")print(str1.find(str2))else:print("The str2 is not in str1")print(str1.find(str2))str_find()

