【Python】实现字符串分割功能 类似于str.split()

s = """   1asdf    2asdf       3asdf    4asdf       5asdf
6asdf     7asdf  8asdf   9asdf    10asdf"""

s = s.strip()

a=b=0

print '==== start ===='

while b !=-1:
    while s[a]==" ":
        a = a+1      
    b = s.find(" ",a)
    if(b == -1):
        print s[a:]
    else:
        print s[a:b]
    a=b

print '==== end ==='

你可能感兴趣的:(【Python】实现字符串分割功能 类似于str.split())