How to urlencode a querystring in Python?

后端 未结 13 1918
猫巷女王i
猫巷女王i 2020-11-22 11:19

I am trying to urlencode this string before I submit.

queryString = \'eventName=\' + evt.fields[\"eventName\"] + \'&\' + \'eventDescription=\' + evt.fie         


        
13条回答
  •  独厮守ぢ
    2020-11-22 11:31

    For Python 3 urllib3 works properly, you can use as follow as per its official docs :

    import urllib3
    
    http = urllib3.PoolManager()
    response = http.request(
         'GET',
         'https://api.prylabs.net/eth/v1alpha1/beacon/attestations',
         fields={  # here fields are the query params
              'epoch': 1234,
              'pageSize': pageSize 
          } 
     )
    response = attestations.data.decode('UTF-8')
    

提交回复
热议问题