Python - 'ascii' codec can't decode byte \xbd in position
问题 I'm using LXML to scrape some text from webpages. Some of the text includes fractions. 5½ I need to get this into a float format. These fail: ugly_fraction.encode('utf-8') #doesn't change to usable format ugly_fraction.replace('\xbd', '') #throws error ugly_freaction.encode('utf-8').replace('\xbd', '') #throws error 回答1: unicodedata.numeric: Returns the numeric value assigned to the Unicode character unichr as float. If no such value is defined, default is returned, or, if not given,