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()
最新推荐文章于 2023-10-27 11:44:42 发布