01
如今机器学习,深度学习的火热,促使python称为一门主流语言。今天花三分钟时间,学一个实际用到的1个小功能,join。
02
字符串list的连接
已知以下字符串:
seq1 = ['hello','good','boy','doiido']
我想通过 分号,分割,将 seq1组合起来,怎么做呢?
可以使用 join 接口,
rslt = '; '.join(seq1)
rslt
Out[3]:
'hello; good; boy; doiido'
join 接口的官方解释:
join(...) method of builtins.str instance S.join(iterable) -> str Return a string which is the concatenation of the strings in the iterable. The separator between elements is S.
中文翻译:返回一个字符串,在可迭代对象的元素组合,它们之间的分隔符是 S