[Tutor] Inserting special characters into urlencoded string

pa yo payo2000 at gmail.com
Tue Feb 10 18:08:26 CET 2009

Novice programmer here.

I am using urllib.urlencode to post content to a web page:

>>Title = "First Steps"
>>Text = "Hello World."
>>Username = "Payo2000"
>>Content = Text + "From: " + Username
>>SubmitText = urllib.urlencode(dict(Action = 'submit', Headline = Title, Textbox = Content))
>>Submit = opener.open('http://www.website.com/index.php?', SubmitText)

This works fine to produce in this:

"Hello World From Payo2000"

...on the page.

However I can't work out how to add a linefeed (urlencode: %0A) in
front of Username so that I get:

"Hello World.
From: Payo2000"

Any hints, tips or suggestions welcome!


More information about the Tutor mailing list