def count_adjacent_repeats(haystack, needle):
if '' in (haystack, needle) or needle not in haystack:
return []
counts = []
for s in haystack.split(needle)[:-1]:
if s == '':
if counts == []:
counts.append(0)
counts[-1] += 1
else:
counts.append(1)
return counts
这样行吗
相关问题 更多 >
编程相关推荐