求助!用了matplotlib之后总报错
代码import json
import requests
import wordcloud
import matplotlib
url = 'https://api.yimian.xyz/coro'
city_dict = {}
data = requests.get(url).text
json_data = json.loads(data)
for p in json_data:
if 'cities' in p:
for c in p['cities']:
city_name = c['cityName']
ccount = c['confirmedCount']
sCount = c['suspectedCount']
total = int(ccount) + int(sCount)
city_dict = total
else:
city_name = p['provinceName']
ccount = p['confirmedCount']
sCount = p['suspectedCount']
total = int(ccount) + int(sCount)
city_dict = total
with open('city.txt', 'w')as f:
for k, v in city_dict.items():
f.write(f'{k}:{v}\n')
ccloud = wordcloud.WordCloud(font_path='\Windows\Fonts\msyh.ttf')
ccloud.generate_from_frequencies(frequencies=city_dict)
matplotlib.figure()
matplotlib.imshow(ccloud, interpolation='bilinear')
matplotlib.axis('off')
matplotlib.show()
报错
matplotlib不是类,from matplotlib import pyplot调用
页:
[1]