使用包含要替换的字符列表的正则表达式
import re
a = re.sub(u'[|•]', ',', a)
句法:
re.sub(pattern, repl, string, max=0)
此方法用 repl 替换字符串中所有出现的 RE 模式,除非提供了max ,否则替换所有出现。
编辑您必须在源文件的顶部声明它使用 Unicode 文字。
# -*- coding: utf-8 -*-
还使用u搜索前缀字符串
a = u"6• 918417•12"
a = re.sub(u"[|•]", ",", a)