M
M
Maxim2020-08-12 15:12:34
Python
Maxim, 2020-08-12 15:12:34

How to rename the resulting file in Python without changing its extension?

I receive an email, and if it has an attachment, I receive that as well. Then I send this letter along with an attachment to telegram. But the problem is that if the file name in the attachment is in Russian, then I get an error

TypeError: decoding to str: need a bytes-like object, Header found

How did you solve the problem with the Cyrillic alphabet?

PS: the encoding is set in the script header
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Gornostaev, 2020-08-12
@MaxRAF

I read the "Unicode HOWTO" section of the documentation, I had no problems with Cyrillic.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question