自己设计一个分割函数,根据不同字符,其中的点号可以改为其他符号
****************************************************************************************
s = ‘xbc..w1z2x......yd3c....eeff‘
print(s)
#s = s.strip()
#print(s)
sep = ‘..‘
def my_split(src, sep):
a = s.find(sep)
w1 = s[:a]
print(w1)
b = a
i = 0
n = len(sep)
while b <= len(s) and b != -1:
while s[a:a + n] == sep:
a = a + n
b = s.find(sep, a)
if b != -1:
print(s[a:b])
else:
print(s[a:])
a = b
i = i + 1
print(‘enter my_split‘)
my_split(s, sep)
print(‘=============================‘)
my_split(s, ‘.‘)
print(‘=============================‘)
my_split(s, ‘...‘)
print(‘leave my_split‘)