python:MySplit():以任意单字符为标志分隔字符串(除了反斜杠\)
MySplit():以任意单字符为标志分隔字符串(除了反斜杠\)(转义符问题)
# split a string by q no matter how many q separated them
def mysplit(str, q) :
b = str.split(q)
ans = list()
for i in range(len(b)):
if b[i] != '':
ans.append(b[i])
return ans
######################
# 例子
a = mysplit('qqwweeqqwweecamsceesac', 'ee')
print(a)
# ['qqww', 'qqww', 'camsc', 'sac']
moyutime:本文仅是学习心得,观点仅供参考,祝愿读者学习途中快乐且不断有所收获。