标签:col src spl nbsp mamicode sep because inf com
Python split() 通过指定分隔符对字符串进行切片
切片之后为list数据类型。
sentence = ‘I can because I think I can ‘ s_1 = sentence.split(sep=‘ ‘, maxsplit=2) s_2 = sentence.split() # sep默认为所有的空字符,包括空格、换行(\n)、制表符(\t)等;maxsplit默认为 -1, 即分隔所有。 s_4 = ‘-‘ s_5 = [‘1‘, ‘2‘, ‘3‘] s_6 = s_4.join(s_5) print(‘s_1‘, s_1) print(‘s_2‘, s_2) print(‘type(s_2)‘, type(s_2)) print(‘s_6‘, s_6) print(‘type(s_6)‘, type(s_6))
标签:col src spl nbsp mamicode sep because inf com
原文地址:https://www.cnblogs.com/qianslup/p/11827346.html