我用了requests模块,能直接拿到json格式的值了,但是我接下来按照课程里说的,增加data = json.loads(content),转换成字典,程序报错了,报错是TypeError: the JSON object must be str, bytes or bytearray, not 'dict'
代码如下:
# -*- coding: utf-8 -*-
import urllib.request # 导入import urllib.request,python3用
import requests
import json
from city import city # 前一个“city”是模块名,也就是py文件的名称,后一个“city”是模块中变量的名称。