E
E
enabl32018-01-29 15:01:01
Python
enabl3, 2018-01-29 15:01:01

How to treat a Telegram bot crash if a user with Cyrillic in his nickname writes to him?

The bot is based on python, authorization by chatID is screwed on it.
If a user who has a username in which there is Cyrillic writes to him, he falls.
Until recently, everything was fine.
Can you tell me why and how to fix it?
Thank you.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
enabl3, 2018-01-29
@enabl3

Solved with:

import sys
reload(sys)
sys.setdefaultencoding('utf8')

Auto-encoding conversion

D
DarkMode, 2018-01-29
@DarkMode

Insert at the beginning of the script.
# -*- coding: utf-8 -*-

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question