replace é python code example
Example 1: convert accented characters to normal python
import unicodedata
def strip_accents(text):
try:
text = unicode(text, 'utf-8')
except NameError:
pass
text = unicodedata.normalize('NFD', text)\
.encode('ascii', 'ignore')\
.decode("utf-8")
return str(text)
s = strip_accents('àéêöhello')
print s
Example 2: python replace
string = "[Message]"
string = string.replace("[", "")
string = string.replace("]", "")
print(string)
Example 3: unicodedata no accent
import unicodedata
def strip_accents(s):
return ''.join(c for c in unicodedata.normalize('NFD', s)
if unicodedata.category(c) != 'Mn')