最新国产好看的视频,伊人天堂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)論

天门市| 英超| 元氏县| 阜平县| 厦门市| 张家界市| 衡阳市| 武安市| 无极县| 云林县| 娄烦县| 迁安市| 沾化县| 忻州市| 星座| 库尔勒市| 怀柔区| 玉田县| 普格县| 郎溪县| 武定县| 广德县| 房产| 油尖旺区| 蓬莱市| 淮南市| 大厂| 澎湖县| 南川市| 偏关县| 铜陵市| 观塘区| 兴城市| 高州市| 五河县| 伊川县| 富源县| 永平县| 梁山县| 汕尾市| 抚顺县|