This question already has answers here:
Closed 4 years ago.
The below code is working fine on Python 2 but on Python 3 I get the error:
"ImportError: No module named 'urllib2'"
import urllib2
peticion = 'I'm XML'
url_test = 'I'm URL'
req = urllib2.Request(url=url_test,
data=peticion,
headers={'Content-Type': 'application/xml'})
respuesta = urllib2.urlopen(req)
print(respuesta)
print(respuesta.read())
respuesta.open()
Please suggest me the reason of error.
Thank you.