简体   繁体   中英

Decode error - output not utf-8

If I try to have Python print the string "«»••" , it instead returns

[Decode error - output not utf-8] .

How can I fix this? I'm using Sublime Text 2, if it helps.

EDIT: Apparently,

print("«»••")

works, but not

print("Hello world!   «»••")

Note that I'm using this at the top of the file:

# -*- coding: utf-8 -*-

EDIT x2:

repr("Hello world!   «»••")

returns

'Hello world!   \xc2\xab\xc2\xbb\xe2\x80\xa2\xe2\x80\xa2'

Not 100% sure if this will solve your problem or not but if I try formatting:

# -*- coding: utf8 -*-
print("Hello world!    %s" %"«»••")

I'm able to produce the output that isn't working for you.

Nothing shows up however if they are both contained in the same string. Same error if I try to concatenate the strings as well.

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