The default split
method in Python treats consecutive spaces as a single delimiter. But if you specify a delimiter string, consecutive delimiters are not collapsed:
>>> aaa .split( a )
[ , , , ]
如何最直截了当地打破连续的界线? 我知道,我只能从结果清单中删除空洞之处:
>>> result = aaa .split( a )
>>> result
[ , , , ]
>>> result = [item for item in result if item]
但是,是否有更方便的办法?