Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added exercises/1901080018/QR.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions exercises/1901080018/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
拖拖拉拉的来做第14课。
通过这次编程的学习,大概知道编程在工作、生活中的运用。1.有一个想法-用编程来完成一个任务、解决一个问题。2.有了想法以后再思考怎么样用编程去实现,分解成哪些步骤去实现,或者说将要解决的大问题拆分成若干个小问题。3.再就是每个步骤遇到问题再去解决,关于编程的问题大多数时候都是通过搜索引擎解决的。
接下来继续学习罢,但要找个时间开始。
16 changes: 16 additions & 0 deletions exercises/1901080018/d12/mymodule/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from wxpy import *
bot = Bot()
my_friend = bot.friends().search("波罗",sex=MALE,city='广州')[0]
my_friend.send('我找到你了')
@bot.register(chats =None,msg_types = 'Sharing',except_self = True)
def auto_reply(msg):
import requests
from pyquery import PyQuery
import stats_word
response = requests.get(msg.url)
document = PyQuery(response.text)
content = document('#js_content').text()
list1 = stats_word.stats_text(content,100)
str1 = "".join([str(i) for i in list1])
return str1
embed()
32 changes: 32 additions & 0 deletions exercises/1901080018/d12/mymodule/stats_word.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@


import jieba
import re
import collections
def stats_text_en(en,count):
if isinstance(en,str):
d = {}
t1 = re.sub(u"([^\u0041-\u005a\u0061-\u007a\'])"," ",en)
t2 = t1.split()
d=collections.Counter(t2).most_common(count)
return d
else:
raise ValueError ("输入的不是文本,请重新输入")
def stats_text_cn(cn,count):
if isinstance(cn,str):
d={}
t2=[]
t1=re.sub(u"([^\u4e00-\u9fa5])","",cn)
seg_list = jieba.cut(t1,cut_all=False)
for i in seg_list:
if len(i) >= 2:
t2.append(i)
d=collections.Counter(t2).most_common(count)
return d
else:
raise ValueError("输入的不是文本,请重新输入")
def stats_text(ec,count): #创建stats_text函数
if isinstance(ec,str): #如果ec是字符串,则运行下面一行的代码。
return stats_text_cn(ec,count) + stats_text_en(ec,count) #返回值为stats_text_cn(ec)和stats_text_en(ec)的结果。
else: #否则提示错误:输入的不是文本。。。。。。
raise ValueError ("输入的不是文本,请重新输入")
2,235 changes: 2,235 additions & 0 deletions exercises/1901080018/d12/mymodule/tang300.json

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions exercises/1901080018/d13/fdsfds.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import matplotlib
matplotlib.matplotlib_fname()
33 changes: 33 additions & 0 deletions exercises/1901080018/d13/mymodule/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import requests
from pyquery import PyQuery
import stats_word
from wxpy import *
bot = Bot()
my_friend = bot.friends().search("波罗",sex=MALE,city='广州')[0]
my_friend.send('我找到你了')
@bot.register(chats =None,msg_types = 'Sharing',except_self = True)
def auto_reply(msg):
response = requests.get(msg.url)
document = PyQuery(response.text)
content = document('#js_content').text()
list1 = stats_word.stats_text_cn(content,20)
d1 = dict(list1)
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.font_manager as fm
plt.rcdefaults()
fig,ax = plt.subplots()
plt.rcParams['font.sans-serif'] = ['simhei']
people = list(d1.keys())
y_pos = np.arange(len(people))
performance = list(d1.values())
ax.barh(y_pos,performance,xerr=None,align='center',color='green',ecolor='black')
ax.set_yticks(y_pos)
ax.set_yticklabels(people)
ax.set_xlabel(performance)
ax.invert_yaxis()
ax.set_title('词频排序前20')
plt.savefig('day13.png')
msg.reply_image('day13.png')
plt.show()
embed()
32 changes: 32 additions & 0 deletions exercises/1901080018/d13/mymodule/stats_word.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@


import jieba
import re
import collections
def stats_text_en(en,count):
if isinstance(en,str):
d = {}
t1 = re.sub(u"([^\u0041-\u005a\u0061-\u007a\'])"," ",en)
t2 = t1.split()
d=collections.Counter(t2).most_common(count)
return d
else:
raise ValueError ("输入的不是文本,请重新输入")
def stats_text_cn(cn,count):
if isinstance(cn,str):
d={}
t2=[]
t1=re.sub(u"([^\u4e00-\u9fa5])","",cn)
seg_list = jieba.cut(t1,cut_all=False)
for i in seg_list:
if len(i) >= 2:
t2.append(i)
d=collections.Counter(t2).most_common(count)
return d
else:
raise ValueError("输入的不是文本,请重新输入")
def stats_text(ec,count): #创建stats_text函数
if isinstance(ec,str): #如果ec是字符串,则运行下面一行的代码。
return stats_text_cn(ec,count) + stats_text_en(ec,count) #返回值为stats_text_cn(ec)和stats_text_en(ec)的结果。
else: #否则提示错误:输入的不是文本。。。。。。
raise ValueError ("输入的不是文本,请重新输入")
Loading