Project Name: sfyc23+EverydayWechat
Language: Python
Statement Type: Assignment

Source Code:
def get_air_quality(city):
    """
    通过城市名获取空气质量
    官网：http://aqicn.org/here/
    token 申请地址：http://aqicn.org/data-platform/token/#/
    :param city: 城市
    :return:
    """

    if not city or not city.strip():
        return
    print('获取 {} 的空气质量...'.format(city))
    try:

        url = 'http://api.waqi.info/feed/{city}/?token={token}'.format(city=city, token=AQICN_TOKEN)
        resp = requests.get(url)
        if resp.status_code == 200:
            # print(resp.text)
            content_dict = resp.json()
            if content_dict.get('status') == 'ok':
                data_dict = content_dict['data']
                aqi = data_dict['aqi']
                air_status = '严重污染'
                for key in sorted(AIR_STATUS_DICT):
                    if key >= aqi:
                        air_status = AIR_STATUS_DICT[key]
                        break
                aqi_info = '{city} PM2.5：{aqi} {air_status}'.format(city=city, aqi=aqi, air_status=air_status)
                # print(aqi_info)
                return aqi_info
            else:
                print('获取空气质量失败:{}'.format(content_dict['data']))
                return None
        print('获取空气质量失败。')
    except Exception as exception:
        print(str(exception))
    return None

get_air_quality(city='桂林')

Selected Statement: data_dict = content_dict['data']

Function Input:
city: '桂林'

Variable Values Before Statement:
content_dict: {'status': 'ok', 'data': {'aqi': 50, 'idx': 1552, 'attributions': [{'url': 'http://sthjt.gxzf.gov.cn/', 'name': 'Guangxi Zhuang Autonomous Region Environmental Protection Agency (广西壮族自治区环境保护厅)'}, {'url': 'https://waqi.info/', 'name': 'World Air Quality Index Project'}], 'city': {'geo': [25.273566, 110.290195], 'name': 'Guilin (桂林)', 'url': 'https://aqicn.org/city/guilin', 'location': ''}, 'dominentpol': 'pm25', 'iaqi': {'co': {'v': 9.1}, 'h': {'v': 77}, 'no2': {'v': 4.6}, 'p': {'v': 1012}, 'pm10': {'v': 20}, 'pm25': {'v': 50}, 'so2': {'v': 4.1}, 't': {'v': 18}, 'w': {'v': 4.6}}, 'time': {'s': '2024-04-04 19:00:00', 'tz': '+08:00', 'v': 1712257200, 'iso': '2024-04-04T19:00:00+08:00'}, 'forecast': {'daily': {'o3': [{'avg': 7, 'day': '2024-04-02', 'max': 22, 'min': 4}, {'avg': 3, 'day': '2024-04-03', 'max': 8, 'min': 2}, {'avg': 6, 'day': '2024-04-04', 'max': 12, 'min': 2}, {'avg': 3, 'day': '2024-04-05', 'max': 5, 'min': 1}, {'avg': 6, 'day': '2024-04-06', 'max': 7, 'min': 5}, {'avg': 8, 'day': '2024-04-07', 'max': 13, 'min': 5}, {'avg': 15, 'day': '2024-04-08', 'max': 23, 'min': 10}, {'avg': 15, 'day': '2024-04-09', 'max': 17, 'min': 14}], 'pm10': [{'avg': 47, 'day': '2024-04-02', 'max': 58, 'min': 32}, {'avg': 56, 'day': '2024-04-03', 'max': 83, 'min': 46}, {'avg': 45, 'day': '2024-04-04', 'max': 46, 'min': 41}, {'avg': 29, 'day': '2024-04-05', 'max': 38, 'min': 24}, {'avg': 22, 'day': '2024-04-06', 'max': 28, 'min': 19}, {'avg': 24, 'day': '2024-04-07', 'max': 28, 'min': 19}, {'avg': 22, 'day': '2024-04-08', 'max': 28, 'min': 19}, {'avg': 30, 'day': '2024-04-09', 'max': 38, 'min': 28}, {'avg': 44, 'day': '2024-04-10', 'max': 46, 'min': 28}], 'pm25': [{'avg': 140, 'day': '2024-04-02', 'max': 158, 'min': 98}, {'avg': 153, 'day': '2024-04-03', 'max': 185, 'min': 138}, {'avg': 136, 'day': '2024-04-04', 'max': 138, 'min': 123}, {'avg': 90, 'day': '2024-04-05', 'max': 115, 'min': 70}, {'avg': 72, 'day': '2024-04-06', 'max': 89, 'min': 68}, {'avg': 80, 'day': '2024-04-07', 'max': 89, 'min': 68}, {'avg': 74, 'day': '2024-04-08', 'max': 88, 'min': 68}, {'avg': 89, 'day': '2024-04-09', 'max': 89, 'min': 89}, {'avg': 119, 'day': '2024-04-10', 'max': 138, 'min': 89}], 'uvi': [{'avg': 0, 'day': '2022-10-15', 'max': 0, 'min': 0}, {'avg': 1, 'day': '2022-10-16', 'max': 7, 'min': 0}, {'avg': 1, 'day': '2022-10-17', 'max': 8, 'min': 0}, {'avg': 1, 'day': '2022-10-18', 'max': 8, 'min': 0}, {'avg': 1, 'day': '2022-10-19', 'max': 8, 'min': 0}, {'avg': 1, 'day': '2022-10-20', 'max': 5, 'min': 0}]}}, 'debug': {'sync': '2024-04-04T20:26:23+09:00'}}}

Value After Statement Execution: {'aqi': 50, 'idx': 1552, 'attributions': [{'url': 'http://sthjt.gxzf.gov.cn/', 'name': 'Guangxi Zhuang Autonomous Region Environmental Protection Agency (广西壮族自治区环境保护厅)'}, {'url': 'https://waqi.info/', 'name': 'World Air Quality Index Project'}], 'city': {'geo': [25.273566, 110.290195], 'name': 'Guilin (桂林)', 'url': 'https://aqicn.org/city/guilin', 'location': ''}, 'dominentpol': 'pm25', 'iaqi': {'co': {'v': 9.1}, 'h': {'v': 77}, 'no2': {'v': 4.6}, 'p': {'v': 1012}, 'pm10': {'v': 20}, 'pm25': {'v': 50}, 'so2': {'v': 4.1}, 't': {'v': 18}, 'w': {'v': 4.6}}, 'time': {'s': '2024-04-04 19:00:00', 'tz': '+08:00', 'v': 1712257200, 'iso': '2024-04-04T19:00:00+08:00'}, 'forecast': {'daily': {'o3': [{'avg': 7, 'day': '2024-04-02', 'max': 22, 'min': 4}, {'avg': 3, 'day': '2024-04-03', 'max': 8, 'min': 2}, {'avg': 6, 'day': '2024-04-04', 'max': 12, 'min': 2}, {'avg': 3, 'day': '2024-04-05', 'max': 5, 'min': 1}, {'avg': 6, 'day': '2024-04-06', 'max': 7, 'min': 5}, {'avg': 8, 'day': '2024-04-07', 'max': 13, 'min': 5}, {'avg': 15, 'day': '2024-04-08', 'max': 23, 'min': 10}, {'avg': 15, 'day': '2024-04-09', 'max': 17, 'min': 14}], 'pm10': [{'avg': 47, 'day': '2024-04-02', 'max': 58, 'min': 32}, {'avg': 56, 'day': '2024-04-03', 'max': 83, 'min': 46}, {'avg': 45, 'day': '2024-04-04', 'max': 46, 'min': 41}, {'avg': 29, 'day': '2024-04-05', 'max': 38, 'min': 24}, {'avg': 22, 'day': '2024-04-06', 'max': 28, 'min': 19}, {'avg': 24, 'day': '2024-04-07', 'max': 28, 'min': 19}, {'avg': 22, 'day': '2024-04-08', 'max': 28, 'min': 19}, {'avg': 30, 'day': '2024-04-09', 'max': 38, 'min': 28}, {'avg': 44, 'day': '2024-04-10', 'max': 46, 'min': 28}], 'pm25': [{'avg': 140, 'day': '2024-04-02', 'max': 158, 'min': 98}, {'avg': 153, 'day': '2024-04-03', 'max': 185, 'min': 138}, {'avg': 136, 'day': '2024-04-04', 'max': 138, 'min': 123}, {'avg': 90, 'day': '2024-04-05', 'max': 115, 'min': 70}, {'avg': 72, 'day': '2024-04-06', 'max': 89, 'min': 68}, {'avg': 80, 'day': '2024-04-07', 'max': 89, 'min': 68}, {'avg': 74, 'day': '2024-04-08', 'max': 88, 'min': 68}, {'avg': 89, 'day': '2024-04-09', 'max': 89, 'min': 89}, {'avg': 119, 'day': '2024-04-10', 'max': 138, 'min': 89}], 'uvi': [{'avg': 0, 'day': '2022-10-15', 'max': 0, 'min': 0}, {'avg': 1, 'day': '2022-10-16', 'max': 7, 'min': 0}, {'avg': 1, 'day': '2022-10-17', 'max': 8, 'min': 0}, {'avg': 1, 'day': '2022-10-18', 'max': 8, 'min': 0}, {'avg': 1, 'day': '2022-10-19', 'max': 8, 'min': 0}, {'avg': 1, 'day': '2022-10-20', 'max': 5, 'min': 0}]}}, 'debug': {'sync': '2024-04-04T20:26:23+09:00'}}

Variable States During Runtime (line, value):
city: 1
'桂林'
url: 15
'http://api.waqi.info/feed/桂林/?token=6382db85ef321ae81f316486de0b5b8aa6c84f62'
resp: 16
<Response [200]>
content_dict: 19
{'status': 'ok', 'data': {'aqi': 50, 'idx': 1552, 'attributions': [{'url': 'http://sthjt.gxzf.gov.cn/', 'name': 'Guangxi Zhuang Autonomous Region Environmental Protection Agency (广西壮族自治区环境保护厅)'}, {'url': 'https://waqi.info/', 'name': 'World Air Quality Index Project'}], 'city': {'geo': [25.273566, 110.290195], 'name': 'Guilin (桂林)', 'url': 'https://aqicn.org/city/guilin', 'location': ''}, 'dominentpol': 'pm25', 'iaqi': {'co': {'v': 9.1}, 'h': {'v': 77}, 'no2': {'v': 4.6}, 'p': {'v': 1012}, 'pm10': {'v': 20}, 'pm25': {'v': 50}, 'so2': {'v': 4.1}, 't': {'v': 18}, 'w': {'v': 4.6}}, 'time': {'s': '2024-04-04 19:00:00', 'tz': '+08:00', 'v': 1712257200, 'iso': '2024-04-04T19:00:00+08:00'}, 'forecast': {'daily': {'o3': [{'avg': 7, 'day': '2024-04-02', 'max': 22, 'min': 4}, {'avg': 3, 'day': '2024-04-03', 'max': 8, 'min': 2}, {'avg': 6, 'day': '2024-04-04', 'max': 12, 'min': 2}, {'avg': 3, 'day': '2024-04-05', 'max': 5, 'min': 1}, {'avg': 6, 'day': '2024-04-06', 'max': 7, 'min': 5}, {'avg': 8, 'day': '2024-04-07', 'max': 13, 'min': 5}, {'avg': 15, 'day': '2024-04-08', 'max': 23, 'min': 10}, {'avg': 15, 'day': '2024-04-09', 'max': 17, 'min': 14}], 'pm10': [{'avg': 47, 'day': '2024-04-02', 'max': 58, 'min': 32}, {'avg': 56, 'day': '2024-04-03', 'max': 83, 'min': 46}, {'avg': 45, 'day': '2024-04-04', 'max': 46, 'min': 41}, {'avg': 29, 'day': '2024-04-05', 'max': 38, 'min': 24}, {'avg': 22, 'day': '2024-04-06', 'max': 28, 'min': 19}, {'avg': 24, 'day': '2024-04-07', 'max': 28, 'min': 19}, {'avg': 22, 'day': '2024-04-08', 'max': 28, 'min': 19}, {'avg': 30, 'day': '2024-04-09', 'max': 38, 'min': 28}, {'avg': 44, 'day': '2024-04-10', 'max': 46, 'min': 28}], 'pm25': [{'avg': 140, 'day': '2024-04-02', 'max': 158, 'min': 98}, {'avg': 153, 'day': '2024-04-03', 'max': 185, 'min': 138}, {'avg': 136, 'day': '2024-04-04', 'max': 138, 'min': 123}, {'avg': 90, 'day': '2024-04-05', 'max': 115, 'min': 70}, {'avg': 72, 'day': '2024-04-06', 'max': 89, 'min': 68}, {'avg': 80, 'day': '2024-04-07', 'max': 89, 'min': 68}, {'avg': 74, 'day': '2024-04-08', 'max': 88, 'min': 68}, {'avg': 89, 'day': '2024-04-09', 'max': 89, 'min': 89}, {'avg': 119, 'day': '2024-04-10', 'max': 138, 'min': 89}], 'uvi': [{'avg': 0, 'day': '2022-10-15', 'max': 0, 'min': 0}, {'avg': 1, 'day': '2022-10-16', 'max': 7, 'min': 0}, {'avg': 1, 'day': '2022-10-17', 'max': 8, 'min': 0}, {'avg': 1, 'day': '2022-10-18', 'max': 8, 'min': 0}, {'avg': 1, 'day': '2022-10-19', 'max': 8, 'min': 0}, {'avg': 1, 'day': '2022-10-20', 'max': 5, 'min': 0}]}}, 'debug': {'sync': '2024-04-04T20:26:23+09:00'}}}
data_dict: 21
{'aqi': 50, 'idx': 1552, 'attributions': [{'url': 'http://sthjt.gxzf.gov.cn/', 'name': 'Guangxi Zhuang Autonomous Region Environmental Protection Agency (广西壮族自治区环境保护厅)'}, {'url': 'https://waqi.info/', 'name': 'World Air Quality Index Project'}], 'city': {'geo': [25.273566, 110.290195], 'name': 'Guilin (桂林)', 'url': 'https://aqicn.org/city/guilin', 'location': ''}, 'dominentpol': 'pm25', 'iaqi': {'co': {'v': 9.1}, 'h': {'v': 77}, 'no2': {'v': 4.6}, 'p': {'v': 1012}, 'pm10': {'v': 20}, 'pm25': {'v': 50}, 'so2': {'v': 4.1}, 't': {'v': 18}, 'w': {'v': 4.6}}, 'time': {'s': '2024-04-04 19:00:00', 'tz': '+08:00', 'v': 1712257200, 'iso': '2024-04-04T19:00:00+08:00'}, 'forecast': {'daily': {'o3': [{'avg': 7, 'day': '2024-04-02', 'max': 22, 'min': 4}, {'avg': 3, 'day': '2024-04-03', 'max': 8, 'min': 2}, {'avg': 6, 'day': '2024-04-04', 'max': 12, 'min': 2}, {'avg': 3, 'day': '2024-04-05', 'max': 5, 'min': 1}, {'avg': 6, 'day': '2024-04-06', 'max': 7, 'min': 5}, {'avg': 8, 'day': '2024-04-07', 'max': 13, 'min': 5}, {'avg': 15, 'day': '2024-04-08', 'max': 23, 'min': 10}, {'avg': 15, 'day': '2024-04-09', 'max': 17, 'min': 14}], 'pm10': [{'avg': 47, 'day': '2024-04-02', 'max': 58, 'min': 32}, {'avg': 56, 'day': '2024-04-03', 'max': 83, 'min': 46}, {'avg': 45, 'day': '2024-04-04', 'max': 46, 'min': 41}, {'avg': 29, 'day': '2024-04-05', 'max': 38, 'min': 24}, {'avg': 22, 'day': '2024-04-06', 'max': 28, 'min': 19}, {'avg': 24, 'day': '2024-04-07', 'max': 28, 'min': 19}, {'avg': 22, 'day': '2024-04-08', 'max': 28, 'min': 19}, {'avg': 30, 'day': '2024-04-09', 'max': 38, 'min': 28}, {'avg': 44, 'day': '2024-04-10', 'max': 46, 'min': 28}], 'pm25': [{'avg': 140, 'day': '2024-04-02', 'max': 158, 'min': 98}, {'avg': 153, 'day': '2024-04-03', 'max': 185, 'min': 138}, {'avg': 136, 'day': '2024-04-04', 'max': 138, 'min': 123}, {'avg': 90, 'day': '2024-04-05', 'max': 115, 'min': 70}, {'avg': 72, 'day': '2024-04-06', 'max': 89, 'min': 68}, {'avg': 80, 'day': '2024-04-07', 'max': 89, 'min': 68}, {'avg': 74, 'day': '2024-04-08', 'max': 88, 'min': 68}, {'avg': 89, 'day': '2024-04-09', 'max': 89, 'min': 89}, {'avg': 119, 'day': '2024-04-10', 'max': 138, 'min': 89}], 'uvi': [{'avg': 0, 'day': '2022-10-15', 'max': 0, 'min': 0}, {'avg': 1, 'day': '2022-10-16', 'max': 7, 'min': 0}, {'avg': 1, 'day': '2022-10-17', 'max': 8, 'min': 0}, {'avg': 1, 'day': '2022-10-18', 'max': 8, 'min': 0}, {'avg': 1, 'day': '2022-10-19', 'max': 8, 'min': 0}, {'avg': 1, 'day': '2022-10-20', 'max': 5, 'min': 0}]}}, 'debug': {'sync': '2024-04-04T20:26:23+09:00'}}
aqi: 22
50
air_status: 23
'严重污染'
26
'优'
key: 24
50
aqi_info: 28
'桂林 PM2.5：50 优'