国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > Python > 正文

Python中join和split用法實例

2020-02-23 00:42:45
字體:
來源:轉載
供稿:網友

join用來連接字符串,split恰好相反,拆分字符串的。
不用多解釋,看完代碼,其意自現了。
代碼如下:
>>>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.

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 钦州市| 兰考县| 大荔县| 辽宁省| 惠州市| 巫山县| 通渭县| 湘潭县| 阿尔山市| 含山县| 册亨县| 西林县| 噶尔县| 江城| 镇平县| 横山县| 泾川县| 高唐县| 长泰县| 塘沽区| 锡林郭勒盟| 江华| 定陶县| 石柱| 盐池县| 清远市| 巴林左旗| 平塘县| 邻水| 沂源县| 固原市| 平陆县| 上蔡县| 延庆县| 涟源市| 井冈山市| 闽清县| 黑水县| 祁东县| 温州市| 乌兰察布市|