Skip to content

Instantly share code, notes, and snippets.

@15819373175
15819373175 / 绘制饼图.py
Created October 11, 2025 15:56
ssy学习版
import matplotlib.pyplot as plt
import pandas as pd
df=pd.read_excel('JD手机销售数据.xlsx')
# print(df)二维数组形式
#解决中文乱码
plt.rcParams['font.sans-serif']=['SimHei']
plt.figure(figsize=(10,6))#设置画布大小
labels=df['商品名称']
y=df['北京销量']
print(labels)
import requests
import re
url='https://www.weather.com.cn/weather1d/101310201.shtml'
resp=requests.get(url)#打开浏览器并打开网址
resp.encoding='utf-8'
print(resp.text)
city=re.findall('<span class="name">([\u4e00-\u9fa5]*)</span>',resp.text)
weather=re.findall('<span class="weather">([\u4e00-\u9fa5]*)</span>',resp.text)
wd=re.findall('<span class="wd">(.*)</span>',resp.text)