标签:style class blog code color 代码
def simu_split(sep): s1="www neu edu cn" #s1=s1.strip() length=len(s1) print length a=s1.find(sep) n=len(sep) if a==-1: print s1 elif: print s1[:a], while a<length and a!=-1: while a<length and s1[a:a+n]==sep ://这一步跟标准库的处理不同,标准库是遇到一个 //sep就打印 a+=n b=a a=s1.find(sep,b) if a==-1: print s1[b:length], else: print s1[b:a], else: print "\nelse" print "out of while" simu_split(" ") print "end of the file"
def simu_split(sep): s1="www neu edu cn" #s1=s1.strip() length=len(s1) print length a=s1.find(sep) n=len(sep) if a==-1: print s1 elif: print s1[:a], while a<length and a!=-1: #while a<length and s1[a:a+n]==sep : # a+=n b=a a=s1.find(sep,b) if a==-1: print s1[b:length], elif (b-a)==n: print " " else: print s1[b:a], else: print "\nelse" print "out of while" simu_split(" ") print "end of the file"
标签:style class blog code color 代码
原文地址:http://www.cnblogs.com/wangyichao/p/3796014.html