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 in Python by Kichu
• 15,450 points
12 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 by narikkadan
• 7,860 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
567 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
2,903 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
9,156 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,440 points
567 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 2,745 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 in Python by narikkadan
• 7,860 points
12 views
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP