Avatar ·

写入文件时的编码问题:UnicodeEncodeError: 'charmap' codec can't encode character '\u039a'

📁 python

需要根据指定参数解析vk并将结果写入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','a')while index != (count_index - offset_index):    result.write(str(search_result[index + 1]))    result.write('')    index += 1result.close()

出现错误:

Traceback (most recent call last):  File ""E:***\\vkscript.py"", line 19, in <module>    result.write(str(search_result[index + 1]))  File "