最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Python中join和split用法實(shí)例

 更新時(shí)間:2015年04月14日 10:06:59   投稿:junjie  
這篇文章主要介紹了Python中join和split用法實(shí)例,本文直接給出使用實(shí)例,需要的朋友可以參考下

join用來(lái)連接字符串,split恰好相反,拆分字符串的。
不用多解釋,看完代碼,其意自現(xiàn)了。

復(fù)制代碼 代碼如下:

>>>li = ['my','name','is','bob']
>>>' '.join(li)
'my name is bob'
>>>s = '_'.join(li)
>>>s
'my_name_is_bob'
>>>s.split('_')
['my', 'name', 'is', 'bob']

其join和split的英文版解釋如下:

join(...)
S.join(sequence) -> string

Return a string which is the concatenation of the strings in the
sequence.  The separator between elements is S.

split(...)
S.split([sep [,maxsplit]]) -> list of strings

Return a list of the words in the string S, using sep as the
delimiter string.  If maxsplit is given, at most maxsplit
splits are done. If sep is not specified or is None, any
whitespace string is a separator and empty strings are removed
from the result.

相關(guān)文章

最新評(píng)論

西峡县| 环江| 乳源| 肥西县| 樟树市| 枝江市| 汉寿县| 新巴尔虎右旗| 呈贡县| 淅川县| 旅游| 浠水县| 阿鲁科尔沁旗| 玛多县| 清涧县| 平南县| 历史| 瓮安县| 湖南省| 门源| 汉中市| 平度市| 屯门区| 乐安县| 永宁县| 兰溪市| 遵义县| 革吉县| 乾安县| 济源市| 安岳县| 雷山县| 饶阳县| 安达市| 云阳县| 大港区| 泰顺县| 句容市| 新宁县| 驻马店市| 江陵县|