python 去除字符串中连续的空格,并使用其他的分隔符替代连续的空格
例:1:
filt函数用法及匿名函数lamda用法,详见http://www.cnblogs.com/apple2016/p/5657698.html
join()用法详见http://www.cnblogs.com/apple2016/p/5600977.html
ss=['upay3 27878 1 * ?'] s1=','.join(filter(lambda x: x, ss[0].split(' '))) print (s1)
>>> ================================ RESTART ================================
>>>
upay3,27878,1,*,?
例如2:
ss=['upay3 27878 1 * ?'] s=','.join(filter(lambda x: x, ss[0].split(' '))).split(',')[1] print (s)
>>> ================================ RESTART ================================ >>> 27878

浙公网安备 33010602011771号