当前位置:  首页>> 技术小册>> Python合辑4-130个字符串操作示例

在 Python 中拆分具有多个分隔符的字符串

  1. import re
  2. l = re.split(r'[$-]+', 'canada$-india$-japan$-uae')
  3. print(l)

Output:

  1. ['canada', 'india', 'japan', 'uae']

该分类下的相关小册推荐: