Python数据分析
1、Python爬取网页数据
豆瓣
import requests
if __name__=="__main__":
response = requests.get("https://book.douban.com/subject/211232954/")
content = response.content.decode("utf-8")
print(content)
京东
import requests
url="https://pro.jd.com/mall/active/4BNKTNkDeSxAsydtZ6/index.html"
try:
r=requests.get(url)
r.raise_for_status()
r.encoding=r.apparent_encoding
print(r.text[:100])
except:
print("爬取失败")
2、Python生成柱状图
import matplotlib.pyplot as plt
num_list = [1.5,0.6,7.8,6]
plt.bar(range(len(num_list)), num_list,color='rbgy')
plt.show()
3、Python生成堆状柱状图
import matplotlib.pyplot as plt
name_list = ['Monday',