简体   繁体   中英

python unicode to str exception

I am trying to convert this unicode: u"\★ adasdadad" to str and got this exception:

UnicodeEncodeError: 'ascii' codec can't encode character u'\u2605' in position 0: ordinal not in range(128)

Help please.

u"\u2605 adasdadad".encode("utf8")

也许

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM