Relleno de múltiples caracteres con espacio - python
Enperl
, Puedo hacer lo siguiente con rellenar mis símbolos de puntuación con espacios:
s/([،;؛¿!"\])}»›”؟%٪°±©®।॥…])/ $1 /g;`
EnPython
He intentado esto:
>>> p = u'،;؛¿!"\])}»›”؟%٪°±©®।॥…'
>>> text = u"this, is a sentence with weird» symbols… appearing everywhere¿"
>>> for i in p:
... text = text.replace(i, ' '+i+' ')
...
>>> text
u'this, is a sentence with weird \xbb symbols \u2026 appearing everywhere \xbf '
>>> print text
this, is a sentence with weird » symbols … appearing everywhere ¿
Pero, ¿hay alguna manera de usar algún tipo de símbolo de marcador de posición, p.$1
enperl
donde puedo hacer lo mismo enpython
con 1 expresión regular?