def remove_accents(text):
'''Removes accents from the text
Returns the text with all accents removed
Using “from unidecode import unidecode” is more
sophisticated, but I am not sure whether I can require
“unidecode”.
:param text: The text to change
:type text: string
:rtype: string
Examples:
>>> remove_accents('Ångstrøm')
'Angstrom'
>>> remove_accents('ÅÆæŒœ?øß?ü')
'AAEaeOEoeijossSSu'
'''
return ''.join([
x for x in unicodedata.normalize('NFKD', text)
if unicodedata.category(x) != 'Mn']).translate(TRANS_TABLE)
评论列表
文章目录