opening a url with urllib in python 3

后端 未结 5 664
我在风中等你
我在风中等你 2020-12-24 07:27

i\'m trying to open the URL of this API from the sunlight foundation and return the data from the page in json. this is the code Ive produced, minus the parenthesis around m

5条回答
  •  余生分开走
    2020-12-24 08:04

    In Python 3 You can implement that this way:

    import urllib.request
    u = urllib.request.urlopen("xxxx")#The url you want to open
    

    Pay attention: Some IDE can import urllib(Spyder) directly, while some need to import urllib.request(PyCharm).

    That's because you sometimes need to explicitly import the pieces you want, so the module doesn't need to load everything up when you just want a small part of it.

    Hope this will help.

提交回复
热议问题