# 至少封装出2个函数
def mySplite(strInfo, splitStr):
strList = []
i = 0
while i < len(strInfo):
index = strInfo.find(splitStr)
if index != -1:
temp = strInfo[i:(index):]
if temp != "":
strList.append(temp)
strInfo = strInfo[(index + 1)::]
i = 0
else:
if strInfo != "":
strList.append(strInfo)
break
return strList
def main():
strInfo = input("输入一个任意长度的字符串:")
splitStr = input("分割符:")
strList = mySplite(strInfo, splitStr)
print(strList)
if __name__ == '__main__':
main()
|
|