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

首頁 > 編程 > Python > 正文

Python中join和split用法實例

2019-11-25 17:44:53
字體:
來源:轉載
供稿:網友

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.

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 青川县| 林芝县| 若羌县| 大宁县| 甘南县| 界首市| 沧源| 海宁市| 曲靖市| 霍山县| 乐亭县| 印江| 宁强县| 民权县| 修武县| 晋江市| 栾城县| 新安县| 渭南市| 新河县| 东阿县| 天柱县| 牟定县| 阿尔山市| 绥阳县| 伊通| 兴山县| 平邑县| 泰和县| 光山县| 黑龙江省| 佳木斯市| 泰顺县| 嵩明县| 闻喜县| 许昌县| 乐平市| 吉安县| 扎鲁特旗| 枣强县| 镇安县|