Answer the question
In order to leave comments, you need to log in
Encoding error in python3 UnicodeEncodeError?
UnicodeEncodeError: 'ascii' codec can't encode characters in position 21-24: ordinal not in range(128)
"
user = user_id
my_info = vk.users.get()[0]
my_id = my_info['id']
my_name = my_info['first_name'] + ' ' + my_info['last_name']
target_name = names_list[dialog_list.index(user)]
vv = open(f'{chat_id_path}/{target_name}.txt', 'tw', encoding='utf-8')
vv.close()
vv = open(f'{chat_id_path}/{target_name}.txt', 'tw', encoding='utf-8')
Answer the question
In order to leave comments, you need to log in
Answer: the code is correct, but the server simply does not support UTF-8
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question