Petr Petrov
Petr Petrov

Reputation: 4452

Python: decode to url format

I need convert kyrillic

Астрахань

to

%C0%F1%F2%F0%E0%F5%E0%ED%FC

I try to use

urllib.parse.quote_plus()

bit it returns

%D0%90%D1%81%D1%82%D1%80%D0%B0%D1%85%D0%B0%D0%BD%D1%8C

What should I use to convert to another format?

Upvotes: 1

Views: 49

Answers (1)

Serge Ballesta
Serge Ballesta

Reputation: 149155

I could guess that you are using Windows cp1251 encoding. quote_plus uses by default utf_8, but also support any specific one:

>>> print(urllib.parse.quote_plus('Астрахань', encoding='cp1251'))
%C0%F1%F2%F0%E0%F5%E0%ED%FC

Upvotes: 2

Related Questions