Задать вопрос
@Sushkov
">alert("yohoho")

В чем может быть ошибка?

Сделал так:
try:
                            mess = str(msg).decode("utf-8")
                        except UnicodeEncodeError:
                            mess = str(msg)
                        except UnicodeDecodeError:
                            mess = str(msg)
                        try:
                            with open(os.path.join(DIR,".".join([name,"eml"])),"a") as f:
                                f.write(mess) 
                        except IOError:
                            name = "@noSubject@ " + str(random.getrandbits(100))
                            with open(os.path.join(DIR,".".join([name,"eml"])),"a") as f:
                                f.write(mess)

иногда выбрасывает ошибку:
UnicodeEncodeError: 'ascii' codec can't encode...
в строке
f.write(mess)
Я не понимаю почему?
  • Вопрос задан
  • 286 просмотров
Подписаться 2 3 комментария
Подписчики вопроса 2 К ответам на вопрос (1)