UnicodeEncodeError: ‘utf-8‘ codec can‘t encode characters in position 36-41: surrogates not allowed

address = "\u261d\ufe0f\u261d\ufe0f\u261d\ufe0f\u261d\ufe0f\u0432\u0441\u0435 \u0442\u043e\u0432\u0430\u0440\u044b \u043d\u0430 \u0441\u0430\u0439\u0442\u0435 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438\ud83d\udcf1\ud83d\udcbb\ud83d\udda5\n\u4fc4\u7f57\u65af\uff0c\u514b\u62c9\u65af\u8bfa\u8fbe\u5c14\uff0c\u514b\u62c9\u65af\u8bfa\u8fbe\u5c14\u8fb9\u7586\u533a"
bytes(address, encoding='utf-8', errors='xmlcharrefreplace').decode('utf-8')

>>俄罗斯,克拉斯诺达尔,克拉斯诺达尔边疆区

关于python print时出现UnicodeEncodeError: 'utf-8' codec can't encode character '\ud800' in position 1: surrogates not allowed问题

你可能感兴趣的:(个人学习记录,python)