可以通过使用两个指针遍历两个字符串,并将它们的每个字符进行比较来找到匹配的字符串。下面是一个示例代码:
str1 = "abc"
str2 = "xyz"
len1 = len(str1)
len2 = len(str2)
# 检查两个字符串是否相等
if len1 != len2:
print("The strings are not equal")
else:
# 遍历两个字符串并比较
for i in range(len1):
if str1[i] == str2[i]:
print("Match found!")
else:
print("No match found")
上面的代码可以分别取出两个字符串的每个字符并进行比较。如果两个字符串有一个不同的字符,将停止比较并输出“ No match found”。如果两个字符串完全相等,则输出“Match Found!”