-
(python) split string with multiple separatorsdev/python 2017. 6. 16. 19:58def split(string, *seps):if len(seps) == 0:return stringelif len(seps) == 1:return string.split(seps[0])else:for sep in seps[1:]:string = string.replace(sep, seps[0])return string.split(seps[0])
>>> path = "cls9CityRainy/result/step1/iter_9000/stat"
>>> split(path, '/', '_')
['cls9CityRainy', 'result', 'step1', 'iter', '9000', 'stat']