Answer the question
In order to leave comments, you need to log in
Python, getting started, what to do with encoding?
Started learning Phyton, installed the latest version (tried using pycharm). Everything is clear with the basic examples, I got to the API, I decided to try with vk.com I want to do an elementary thing - Just display the user's First and Last name, specifying the ID. He doesn’t write to me in Russian letters, I get the following error:
Traceback (most recent call last):
File "C:/...../testvk.py", line 9, in <module>
print(test)
File "C:\Python34\lib\encodings\cp1251.py", line 19, in encode
return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\u039f' in position 0: character maps to <undefined>
# -*- coding: utf-8 -*-
import vk
vkapi = vk.API('ID', 'mail', 'Password')
vkapi.access_token = 'token'
profiles = vkapi.users.get(user_id=298845747)
test = (profiles[0]['first_name']+' '+profiles[0]['last_name'])
print(test)
Answer the question
In order to leave comments, you need to log in
He does not write to me in Russian letters,The problematic letter is not Russian, but Greek .
Tell me what I'm doing wrong?Print characters to the console that it does not support. Here are some solutions to the problem. But I recommend that you use other options for displaying information (ie writing to a file or displaying it on a web page).
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question