两种方法:
'''
1.使用split方法,每次处理一种分隔符
2.正则表达式
'''
str = 'dimples 1994 0.0 5454 \\2017/9.27 "haha" '
方法一
def mySplit(s, ds):
res = [s]
for d in ds:
t = []
map(lambda x : t.extend(x.split(d)), res)
res = t
return [x for x in res if x]
print mySplit(str, ';,\|\t"')
方法二
import re
print re.split('[,;\|\t "]+', str)
判断字符串str是否以a开头或结尾
import os, stat
s = 'g.gh'
print s.endswith(('.gh', ',py'))
print [name for name in s if name.endswith(('.sh', ',py'))]