name 'urlopen' is not defined

You did not import the name urlopen.

Since you are using python3, you'll need urllib.request:

        from urllib.request import urlopen

        req = urlopen(...)

or explicitly referring to the request module

        import urllib.request

        req = request.urlopen(...)

in python2 this would be 

        from urllib import urlopen

or use urllib.urlopen.

Note: You are also overriding the name json which is not a good idea.

猜你喜欢

转载自blog.csdn.net/hellocsz/article/details/87997693
今日推荐