Python:解码为url格式

标签 python encoding urllib urlencode

我需要转换基里尔文

Астрахань

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

我尝试使用

urllib.parse.quote_plus()

返回的位

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

我应该使用什么来转换为其他格式?

最佳答案

我猜您正在使用 Windows cp1251 编码。 quote_plus 默认使用 utf_8,但也支持任何特定的:

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

关于Python:解码为url格式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50723922/

相关文章:

带名称输入的 Python 石头/剪刀/布

python - N 维数组使用示例

c# - 检测字节数组C#的编码

python - 函数作为 Python 中的对象 : what exactly is stored in memory?

python - 是否有任何内置函数会阻塞 I/O 而不允许其他线程运行?

encoding - Python 2.7 类型错误 : file() argument 1 must be encoded string without NULL bytes, 不是 str

android - Bixolon sdk编码characters_android

python - 使用 OpenCV 的 VideoCapture 方法进行高效链接处理? {编辑}

python - 谷歌搜索爬虫,Python

Python 3.5.1 urllib 没有属性请求