How to urlencode a querystring in Python

0 votes

I want to urlencode this string before I submit.

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

Can someone help me on this?

Apr 26, 2022 in Python by Kichu
• 19,040 points
649 views

1 answer to this question.

0 votes

Just pass your parameters into urlencode() like:

>>> import urllib

>>> f = { 'eventName' : 'myEvent', 'eventDescription' : 'cool event'}

>>> urllib.urlencode(f)

'eventName=myEvent&eventDescription=cool+event'

For Python 3 or above

Use:

>>> urllib.parse.urlencode(f)

eventName=myEvent&eventDescription=cool+event

I hope this helps.

answered Apr 28, 2022 by narikkadan
• 63,600 points

Related Questions In Python

0 votes
1 answer

How to add a new line in Python?

You can use '\n' for a next ...READ MORE

answered May 2, 2018 in Python by aayushi
• 750 points
1,277 views
0 votes
2 answers

How to calculate square root of a number in python?

calculate square root in python >>> import math ...READ MORE

answered Apr 2, 2019 in Python by anonymous
5,883 views
+1 vote
2 answers

How to print first character of each word in upper case of a string in Python

class Solution:     def firstAlphabet(self, s):             self.s=s              k=''              k=k+s[0]              for i in range(len(s)):                     if ...READ MORE

answered Oct 28, 2020 in Python by Anurag
12,432 views
0 votes
1 answer

How to get the size of a string in Python?

If you are talking about the length ...READ MORE

answered Jun 4, 2018 in Python by aryya
• 7,460 points
1,410 views
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,464 views
0 votes
1 answer
0 votes
1 answer

How do I upgrade the Python installation in Windows 10?

If you have 2.x or 3.x version ...READ MORE

answered Apr 28, 2022 in Python by narikkadan
• 63,600 points
480 views
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP