python 中join方法的用法
February 3, 2015
在Python语言里如何来使用join方法呢?下面举几个例子:
>>> name='lizhanguo wangyuwei lixuehan' >>> a = name.split() >>> a ['lizhanguo', 'wangyuwei', 'lixuehan']
>>> b = ','.join(a) 注:以逗号分隔 >>> b 'lizhanguo,wangyuwei,lixuehan'
>>> c = ' '.join(a) 注:以空格分隔 >>> c 'lizhanguo wangyuwei lixuehan'
0 Comments