我从这里复制了一个简单的正则表达式来删除重音字母,但它给出了一个错误。
import re
import unicodedata
class Profile(models.Model):
name = models.CharField(max_length=200, blank=False)
def name_breakdown(self):
newName = re.sub(r'\p{Mn}', '', unicodedata.normalize('NFKD', self.name.lower()))
return newName
错误:
bad escape \p at position 0
我该怎么做才能解决这个问题?