How to encode a string to ASCII and replace undecodable unicode with ? in Python

1 Answer

0 votes
s = "Python åäöÅÄÖ"
 
es = s.encode(encoding='ascii', errors='replace')
 
print(es)
 
 
 
'''
run:
 
b'Python ??????'
 
'''

 



answered Nov 4, 2021 by avibootz

Related questions

...