0

i need to make and api request and i need to convert a strin like:

"hello i am a special string + i contain special characters?"

into a request format like:

"hello%20i%20am%20a%20special ... ecc"

does python has a library to help me out?

this is my code:

import http.client
conn = http.client.HTTPSConnection("address:port")
conn.request(method="GET", url="/my/target/site?info1=this needs to be converted&info2=also this???", headers=headers)

thanks

dhim
  • 123
  • 1
  • 9

1 Answers1

2

Like in How to convert a url string to safe characters with python? And How to urlencode a querystring in Python?

You can use

import urllib
urllib.parse.quote_plus('string here')
hedy
  • 1,160
  • 5
  • 23