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)Я не понимаю почему?