This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |