def find2(s1, s2):
    for i in range(len(s1)):
        end=i+len(s2)
        if end>len(s1):
            return -1
        else:
            c=s1[i:i+len(s2)]
            if c==s2:
                return i
def find_between(s, left, right):
    



s1 = 'meet #<gua># halfway'
s2 = 'meet #<gua># #<high>#way'
left = '#<'
right = '>#'
content1 = find_between(s1, left, right)
content2 = find_between(s2, left, right)
print('结果1 ', content1)
print('结果2 ', content2)


# 读取文件 操作

def read_file(file_name):
    with open(file_name, 'r') as f:
        # log(f.read())
        return f.read()

1 条评论

  • 1