str1="khloé kardashian"
str1.encode("ascii")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in position 4: ordinal not in range(128)
如何以完美的方式对其进行编码。我也尝试过:
unicode(query,errors='replace')
TypeError: decoding Unicode is not supported
改用utf-8
str1="khloé kardashian"
str1.encode("utf-8")