#encoding=utf-8
import re
str='2016:9:22'
l_str=re.split(':',str)
print(len(l_str))
for item in l_str:
print(item)
str=':2016:9:22'
l_str=re.split(':',str)
print(len(l_str))
for item in l_str:
if item:
print(item)
else:
print('null')
注意:即便split分隔符前边没有数据,在返回的list中也会有一个空值。