+ 7

Python convert codepage

Change codepage utf-8 to cp1251 I want console output 'hello привет' What I need to do? https://code.sololearn.com/c7YIZpbR9iIG/?ref=app

14th Apr 2018, 5:11 PM
shaldem
shaldem - avatar
8 odpowiedzi
+ 9
I've been trying to solve that for Sololearn, but apparently there is a problem with the virtual machine it is running when on code playground - it can't produce proper output encoding to be read by the application.
14th Apr 2018, 5:40 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 8
Yes, unfortunately you can't do anything about it. But in general you can include the following at the top of your script #-*-coding:cp1251;-*-
15th Apr 2018, 8:21 AM
Martin Möhle
Martin Möhle - avatar
+ 7
Martin to write so comment, is it best practice in python? If script codepage utf-8, do we need write it?
15th Apr 2018, 8:30 AM
shaldem
shaldem - avatar
+ 7
shaldem No, usually you dont need to include it because utf-8 is standard
15th Apr 2018, 8:34 AM
Martin Möhle
Martin Möhle - avatar
15th Apr 2018, 1:01 PM
yuri
21st Jun 2018, 10:33 AM
yuri
+ 1
use utf-16. it works.
21st Jun 2018, 9:50 AM
yuri
+ 1
yuri utf-16 does't work too, the same exception
21st Jun 2018, 10:17 AM
shaldem
shaldem - avatar