Avatar ·

Coding problem when writing to the file: Unicodeencodeerror: 'Charmap' Codec Canat Encode Character '\\ U039a'

📁 Advanced Python Topics

It is required to parse vk according to the specified parameters and write the result to a file in python 3.5.

 search_result = api.users.search(sort = sort_index, sex = sex_index, age_to = age_index, offset = offset_index, count = count_index, country = country) result = open('result.txt', 'w') while index != (count_index - offset_index): result.write(str(search_result[index + 1])) result.write('') index += 1 result.close()

I get an error:

 UnicodeEncodeError: 'charmap' codec can't encode character '\\u039a' in position 0: character maps to