Split 分割字符
1. python 自带 split
str = 'datasets\\hpatches-sequences-release\\i_ajuntament\\1.bmp'
split_name = str.split('\\')
python 自带 split 仅可分割单个特定字符
2. re 模块中的 split
import re
str = 'datasets\\hpatches-sequences-release\\i_ajuntament/1.bmp'
spec_str = '/|\\\\' # 混合的话,双斜杠需要四个斜杠
split_name = re.split(spec_str, str)
>>> split_name
['datasets', 'hpatches-sequences-release', 'i_ajuntament', '1.bmp']