urllib.request and urllib2 both not working
I am trying to learn python and I was trying to learn modules. The python
version I am using is python 2.7.4. The module I was trying to learn was
urllib. But whenever I am trying to run the code below I am getting an
error called 'no import named request'. The code is given below.
import urllib.request
class App():
def main(self):
inp = raw_input('Please enter a string\n')
print(inp)
inp = input('Please enter a value\n')
print(inp)
if __name__ == '__main__':
App().main()
Then I tried using urllib2. So I changed the first line with
import urllib2
But then it say 'IndentationError: expected an indented block'. But if I
write
import urllib
then I don't get any error. But then I can't use any of the functions of
that library. Please help me. I am stuck since last night. Thanks in
advance.
No comments:
Post a Comment