Python字符串分隔
str = "this is string example..."
print(str.split( )) # 以空格分隔
['this', 'is', 'string', 'example...']
print(str.split(" ", 1)) # 以空格分隔,只分隔一次
['this', 'is string example...']
print(str.split("s")) # 以字母分隔
['thi', ' i', ' ', 'tring example...']
print(str.split( )[0])
this
最后更新于