Answer the question
In order to leave comments, you need to log in
How to send text with line breaks (line brakes) in Python3?
Hello, I am newbie in python.
Requires POST request to send text with line breaks to HTTP backend (not python).
Can anyone show an example with multipart form data? The problem is that all this needs to be solved with the help of standard libraries, without resorting to such as requests and the like. Google is already sick of my requests, thanks in advance for the answers.
Answer the question
In order to leave comments, you need to log in
import urllib2
boundary = '85fc538bf62b'
data = """--{0}
Content-Disposition: form-data; name="param_name"
param_value
--{0}--
""".format(boundary)
request = urllib2.Request('http://google.com', data=data, headers={'Content-Type': 'multipart/form-data; boundary={0}'.format(boundary)})
response = urllib2.urlopen(request).read()
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question