python split 与join

1.string.join (saq):以string 为分隔符,将seq中所有的元素(字符串表示"")合并成一个新的字符串

2.string.split(str="",num=string.count(str)):以str做分隔符切string,num表示分隔几个字符串

s='a b c'
print s.split(' ')
st='hello world'
print st.split('o')
print st.split('o',1)

--------output---------
['a', 'b', 'c']
['hell', ' w', 'rld']
['hell', ' world']

原文地址:https://www.cnblogs.com/chenya/p/4218742.html