这篇文章主要介绍了python列表常用操作函数,具有一定借鉴价值,需要的朋友可以参考下。希望大家阅读完这篇文章后大有收获,下面让小编带着大家一起了解一下。
大家好,小编来为大家解答以下问题,python大作业有哪些题目,python大作业100行代码,现在让我们一起来看看吧!
importrequestsimportrefrom bs4 importBeautifulSoupfrom datetime importdatetimeimportpandasimportsqlite3importjiebafrom wordcloud importWordCloudimportmatplotlib.pyplot as plt
url= ""f=open("","w+")
(url)
res0.encoding="utf-8"soup= BeautifulSoup(,"html.parser")
newsgroup=[]for news in soup.select("li"):if len(news.select("a"))>0:print(news.select("a")[0].text)
title=news.select("a")[0].text
f.write(title)
f.close()
f0= open('','r')
qz=[]
()
f0.close()print(qz)
words=list((qz))
ul={':','的','"','、','”','“','快码论文。','!',':','?',' ','\u3000',',','\n'}
dic={}
keys= set(words)-ulfor i inkeys:
dic[i]=words.count(i)
c=list(dic.items())
c.sort(key=lambda x:x[1],reverse=True)
f1= open('','w')for i in range(10):print(c[i])for words_count in range(c[i][1]):
f1.write(c[i][0]+' ')
f1.close()
df=pandas.DataFrame(words)print(())
with sqlite3.connect('newsdb3.sqlite') as db:
df.to_sql('newsdb3',con =db)
f3= open('','r')
()
f3.close()
cy=WordCloud().generate(cy_file)
plt.imshow(cy)
("off")
()
原文地址1:https://blog.csdn.net/ai_lover_cat/article/details/132252529
参考资料:python中用turtle画一个圆形 https://blog.csdn.net/SXIAOYAN_/article/details/140061099