简体   繁体   中英

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM