A
A
azatbairamov2015-11-10 23:16:27
Python
azatbairamov, 2015-11-10 23:16:27

How to pass Cyrillic in URL?

I am writing in Python 3. I need "fun" to be converted to %D0%B2%D0%B5%D1%81%D1%91%D0%BB%D0%BE%D0%B5 (and any word in general). Tried using code like this
#!/usr/bin/python
# -*- coding: utf-8 -*-
from urllib.parse import quote
name=input()
print(quote(name))
but on another PC everything is output right.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
abcd0x00, 2015-11-11
@azatbairamov

>>> import urllib.parse
>>> 
>>> s = 'весёлое'
>>> urllib.parse.quote(s)
'%D0%B2%D0%B5%D1%81%D1%91%D0%BB%D0%BE%D0%B5'
>>>

A
Alexander Pupkin, 2015-11-10
@sakrab

name = input(u'');
Didn't check :D

J
JRazor, 2015-11-11
@JRazor

Why are there so many posts about unicode lately? habrahabr.ru/post/135913

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question