K
K
kommov2017-09-12 14:26:43
Python
kommov, 2017-09-12 14:26:43

How to encode all ascii characters into url code characters in python?

Here is a table of url codes www.weblabla.ru/reference/html/url_encode.html
It is necessary that all suitable characters in the string be converted to them. For example, print('T t1-2') should output the following text:
>>>>%54%20%74%31%96%32
Tried methods:

requests.utils.quote
urllib.parse.urlencode
urllib.parse.quote
urllib.parse.quote_plus
urllib.request.pathname2url

But they only convert whitespace (T%20t1-2). Who can suggest a solution?
(python 3.6.1)

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question