Skip to content

Commit 0405b18

Browse files
authored
Merge pull request selfteaching#5 from selfteaching/master
daily rebase
2 parents bd87aed + 4ddc78e commit 0405b18

File tree

976 files changed

+260517
-1208
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

976 files changed

+260517
-1208
lines changed

1901010091/1001S02E01_helloworld.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
its a new start

1901010091/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
自学pathon第一天,作业在merge部分,提交pull requst搞不清对象,谁像谁提交,谁像谁merge呢

1901040027/1001S02E02_hello_python.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
print("hello world")

19100101/Shawn/d12_training2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def get_msg (msg) :
1212
if msg.type == 'Sharing' :
1313
target_url = msg.url
1414
stats_msg = d12_training1.stats(target_url)
15-
my_friend.send(stats_msg)
15+
msg.reply(stats_msg)
1616
else :
1717
pass
1818
embed()

19100101/Shawn/d13_training3.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import matplotlib.pyplot as plt
2+
import matplotlib.font_manager as fm
3+
4+
cnfont = fm.FontProperties(fname='/Users/Library/Fonts/s.ttf')
5+
6+
7+
def chartImg(data={}) :
8+
group_x = list(data.values())
9+
group_y = list(data.keys())
10+
fig, ax = plt.subplots()
11+
# 自定义表格标签及标题样式
12+
plt.title('词频统计表',color='black',fontproperties = cnfont,fontsize = 16)
13+
ax.set_xlabel('数量',fontproperties = cnfont, color = 'grey')
14+
ax.set_ylabel('词语',fontproperties = cnfont, color = 'grey')
15+
# 绘制图表
16+
ax.set_yticklabels(group_y,fontproperties = cnfont)
17+
ax.barh(group_y,group_x)
18+
19+
plt.savefig('chart.png')
20+
return 'chart.png'

19100101/WangRui0802/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,15 @@ Day10
7272
Day11
7373
慢慢来今天要被一个问题弄死了!“from mymodule import stats_word”这行导入函数一直报错。
7474
把文件目录截图给教练和战友看了,也没看出啥来。我就不再纠结了,很简单粗暴的从头来了一遍。重新建文件夹,重新写函数。这个报错就没有再出现过。也许我们是要认真分析错误的原因,但是在入门的时候,真的不妨从头再来,不怕从零开始去反复。
75+
76+
Day12
77+
今天出了些特殊的事情,没能按时完成作业。回到家就过了24点了。自己在研究作业的时候,有一种难得的安静。钉钉群里大家已经做完了,你知道自己也可以到达,但是在过程中会出现什么问题你是不会知道的。
78+
我首先碰到了KeyError: 'pass_ticket'报错,查了是微信小号登不了网页版微信。
79+
之后出现IndexError: list index out of range报错。查找错误原因的时候,发现自己不太能看懂。只能比较战友们的作业,尝试找到一点启发。随着改动,运行的结果有一点点进展,但还是没得到任务里要求的完整结果。
80+
这次因为过了deadline,群里既没有教练也没有战友,所以就是自己踏踏实实地自己尝试找原因和解决方案。过程里自己云里雾里,一头雾水,但是也挺有趣。发了issue,希望明天,不对,是天亮了能得到大家的解答。彻底弄明白自己被啥卡住了。
81+
也许这就是自学的又一个感悟,你能安安静静地自己学习和面对错误。不急躁,不焦虑,抽丝剥茧寻找蛛丝马迹。最糟的结果就是尽了自己的努力也没啥进展,不是还可以po出来,寻找他人的帮助嘛!
82+
自学很有意思啊!
83+
84+
Day13
85+
磕磕绊绊、囫囵吞枣地走到了第13天。心情很复杂啊!只是有一点就是无论自学的手艺还是编程的手艺,都得自己慢慢磨。在这些天里,没有因为任何原因放弃过就是我最好的体验!
7586

19100101/WangRui0802/d11_training1.py

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,26 @@
11
# Date:19/03/28
22

33
import requests
4-
import yagmail
5-
import getpass
4+
# import yagmail
5+
# import getpass
66
from pyquery import PyQuery
77
from mymodule import stats_word
88

9-
sender = input('请输入发件人邮箱地址:')
10-
psw = input('请输入发件人邮箱登录密码:')
11-
recipient = input('请输入收件人邮箱地址:')
12-
smtp = 'smtp.qq.com'
9+
# sender = input('请输入发件人邮箱地址:')
10+
# psw = input('请输入发件人邮箱登录密码:')
11+
# recipient = input('请输入收件人邮箱地址:')
12+
# smtp = 'smtp.qq.com'
1313

14-
response = requests.get('https://mp.weixin.qq.com/s/pLmuGoc4bZrMNl7MSoWgiA')
14+
def stats (url,num):
15+
response = requests.get(url)
16+
document = PyQuery (response.text)
17+
content = document ('#js_content').text()
1518

16-
document = PyQuery (response.text)
17-
content = document ('#js_content').text()
19+
statList = stats_word.stats_text(content,num)
20+
#statString = ''.join(str(i) for i in statList)
21+
statDict = dict(statList)
22+
return statDict
1823

19-
statList = stats_word.stats_text(content, 100)
20-
statString = ''.join(str(i) for i in statList)
21-
22-
yagmail.SMTP(sender,psw,smtp).send(recipient,'19100101 WangRui0802',statString)
24+
# yagmail.SMTP(sender,psw,smtp).send(recipient,'19100101 WangRui0802',statString)
2325

2426

19100101/WangRui0802/d12_training2.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Date : 19/03/29
2+
3+
from wxpy import *
4+
import d11_training1 as st
5+
import d13_training3 as fg
6+
bot = Bot()
7+
8+
# 找到好友并发消息
9+
my_friend = bot.friends()
10+
11+
# 获取分享文章url
12+
@bot.register(my_friend)
13+
def get_msg (msg) :
14+
if msg.type == 'Sharing' :
15+
retext = st.stats(msg.url, 5)
16+
remsg = fg.chartImg(retext)
17+
msg.reply_image(remsg)
18+
else :
19+
pass
20+
embed()

19100101/WangRui0802/d13_training3.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Date: 19/03/30
2+
3+
import matplotlib.pyplot as plt
4+
import matplotlib.font_manager as fm
5+
6+
# 设置中文字体
7+
cnfont = fm.FontProperties(fname='/Users/Qiming/Library/Fonts/SimHei.ttf')
8+
9+
# 定义绘制图标函数并保存为图片
10+
def chartImg(data={}) :
11+
group_x = list(data.values())
12+
group_y = list(data.keys())
13+
fig, ax = plt.subplots()
14+
# 自定义表格标签及标题样式
15+
plt.title('词频统计表',color='black',fontproperties = cnfont,fontsize = 16)
16+
ax.set_xlabel('数量',fontproperties = cnfont, color = 'grey')
17+
ax.set_ylabel('词语',fontproperties = cnfont, color = 'grey')
18+
# 绘制图表
19+
ax.set_yticklabels(group_y,fontproperties = cnfont)
20+
ax.barh(group_y,group_x)
21+
# 保存绘制文件
22+
plt.savefig('chart.png')
23+
return 'chart.png'
24+
25+

19100101/YanHuiii/d12_training2.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
将信息中的主要内容提取及获取词频反馈,并把结果发给好友的程序'''
33

44
import training1
5+
import d13_training3
56
from wxpy import *
67

78
'''登录微信'''
@@ -13,7 +14,8 @@
1314
def SHARING_Msg (msg) :
1415
if msg.type == 'Sharing' :
1516
url = msg.url
16-
msg.reply(training1.stats_meg(url))
17+
18+
msg.reply(d13_training3.Horizontal_bar_chart(training1.stats_meg(url)))
1719
else :
1820
print("您的好友还没发给您关于分享类型的信息")
1921

19100101/YanHuiii/d13_training3.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
'''这是一个将数据可视化后,把结果发给用户的程序'''
2+
3+
import matplotlib.pyplot as plt
4+
import numpy as np
5+
6+
7+
def Horizontal_bar_chart(data):
8+
'''修复随机状态'''
9+
np.random.seed(19680801)
10+
11+
'''不知道在干什么,好像是定义变量'''
12+
plt.rcdefaults()
13+
fig, ax = plt.subplots()
14+
15+
'''处理数据'''
16+
words = (data[0])
17+
y_pos = np.arange(len(words))
18+
number = 3 + 10* np.random.rand(len(words))
19+
error = np.random.rand(len(words))
20+
21+
'''设置图表样式'''
22+
ax.barh(y_pos,number,xerr = error,align = 'center',color = 'bule',ecolor = 'black')
23+
ax.set_yticks(y_pos)
24+
ax.set_yticklabels(words)
25+
ax.invert_yaxis()
26+
ax.set_xlabel('出现次数')
27+
ax.set_title('关于您发给我分享文章中的中文词频统计图表')
28+
29+
return plt.show()
Binary file not shown.

19100101/qiming09/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
2019.3.30
2+
1. learn to use 3rd-party library "matplotlib" to make charts.
3+
2. send image to wechat friend.
4+
15
2019.3.29
26
1. learn to use 3rd-party libraby "wxpy".
37
2. use "wxpy" to get others' message, analysis this message and reply the result.

19100101/qiming09/d11_training1.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,26 @@
22
# date : 2019.3.28
33
# author by : qiming
44

5+
# update date : 2019.3.30
6+
# content: add argument 'num' to funciton 'stats()'
7+
# update by : qiming
8+
59
import requests
610
from pyquery import PyQuery
711
from mymodule import stats_word
812

913

1014
# 定义stats函数,通过url获取文本并分析
11-
def stats (url) :
15+
def stats (url,num) :
1216
response = requests.get(url)
1317
# 提取微信公众号正文
1418
document = PyQuery (response.text)
1519
content = document ('#js_content').text()
1620
# 统计前100词频
17-
statList = stats_word.stats_text(content,100)
18-
statString = ''.join(str(i) for i in statList)
19-
20-
return statString
21-
22-
21+
statList = stats_word.stats_text(content,num)
22+
# statString = ''.join(str(i) for i in statList)
23+
statDict = dict(statList)
24+
return statDict
2325

2426
# 发送邮件功能的实现方法(暂不需要)
2527
# import yagmail

19100101/qiming09/d12_training2.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,25 @@
22
# date : 2019.3.29
33
# author by : qiming
44

5-
from wxpy import *
6-
import d11_training1
7-
bot = Bot()
5+
# updat date : 2019.3.30
6+
# content : modify reply message type.
7+
# update by :qiming
8+
9+
from wxpy import Bot,Message,embed
10+
import d11_training1 as st
11+
import d13_training3 as fg
812

9-
# 找到好友并发消息
10-
my_friend = bot.friends().search('Somebody')[0]
11-
my_friend.send('请给我分享一篇文章')
13+
# 初始化机器人
14+
bot = Bot()
15+
my_friend = bot.friends()
1216

13-
# 获取分享文章url
17+
# 监听分享消息,并回复分析结果
1418
@bot.register(my_friend)
1519
def get_msg (msg) :
1620
if msg.type == 'Sharing' :
17-
target_url = msg.url
18-
stats_msg = d11_training1.stats(target_url)
19-
my_friend.send(stats_msg)
21+
retext = st.stats(msg.url,5)
22+
remsg = fg.chartImg(retext)
23+
msg.reply_image(remsg)
2024
else :
2125
pass
2226
embed()

19100101/qiming09/d13_training3.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# this is d13 excercise for 3rd-party library "matplotlib" and "numpy"
2+
# date : 2019.3.30
3+
# author by : qiming
4+
5+
import matplotlib.pyplot as plt
6+
import matplotlib.font_manager as fm
7+
8+
# 设置中文字体
9+
cnfont = fm.FontProperties(fname='/Users/Qiming/Library/Fonts/SimHei.ttf')
10+
11+
# 定义绘制图标函数并保存为图片
12+
def chartImg(data={}) :
13+
group_x = list(data.values())
14+
group_y = list(data.keys())
15+
fig, ax = plt.subplots()
16+
# 自定义表格标签及标题样式
17+
plt.title('词频统计表',color='black',fontproperties = cnfont,fontsize = 16)
18+
ax.set_xlabel('数量',fontproperties = cnfont, color = 'grey')
19+
ax.set_ylabel('词语',fontproperties = cnfont, color = 'grey')
20+
# 绘制图表
21+
ax.set_yticklabels(group_y,fontproperties = cnfont)
22+
ax.barh(group_y,group_x)
23+
# 保存绘制文件
24+
plt.savefig('chart.png')
25+
return 'chart.png'

19100101/sundyyang/d13_training3.py

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
2+
# 导入模块
3+
import matplotlib.pyplot as plt
4+
import numpy as np
5+
from wxpy import *
6+
from mymodule import stats_word
7+
from pyquery import PyQuery
8+
import requests
9+
10+
'''
11+
1、调用day12方法,获取统计结果
12+
2、将结果导入day13处理,并生成图片
13+
3、将图片传回day12,并发给朋友
14+
'''
15+
16+
import matplotlib.font_manager as mfm
17+
18+
font = mfm.FontProperties(fname='/System/Library/Fonts/PingFang.ttc')
19+
20+
21+
# 初始化机器人,扫码登陆
22+
bot = Bot()
23+
24+
'''
25+
my_friend = bot.friends().search('亲宝儿')[0] # 测试用
26+
my_friend.send('给我分享篇文章试下')
27+
'''
28+
29+
@bot.register(my_friend)
30+
def print_others(msg):
31+
print (msg.type)
32+
if msg.type =='Sharing':
33+
34+
response = requests.get(msg.url) # 请求获得内容
35+
36+
document = PyQuery(response.text) # 解析提出内容
37+
content = document('#js_content').text()
38+
39+
result = stats_word.stats_text(content)
40+
content1 = result.most_common(20)
41+
day12 = str(content1)
42+
print(day12)
43+
44+
# 拆分
45+
data = dict(content1)
46+
keys, values = zip(*data.items())
47+
48+
plt.rcdefaults()
49+
fig, ax = plt.subplots()
50+
51+
# Example data
52+
people = (content1)
53+
y_pos = np.arange(len(content1))
54+
cipin = values
55+
56+
ax.barh(y_pos, cipin, align='center',color='green', ecolor='black')
57+
ax.set_yticks(y_pos)
58+
ax.set_yticklabels(keys,fontproperties=font)
59+
ax.invert_yaxis() # labels read top-to-bottom
60+
ax.set_xlabel('词频',fontproperties=font)
61+
ax.set_title('文章词频查询结果',fontproperties=font)
62+
63+
plt.savefig('day13.png')
64+
msg.reply_image('day13.png')
65+
66+
embed() # 让程序保持运行
67+

19100101/xiaoguaishou01/_configtest.f

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
subroutine simple
3+
end
4+

19100101/xiaoguaishou01/d11_training1.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,7 @@ def auto_text(url):
88
r = requests.get(url)
99
document = PyQuery(r.text)#提取公众号正文
1010
content = document('#js_content').text()
11-
12-
result = stats_word.stats_text(content,100)
13-
result1 = str(result)
14-
return result1
11+
return stats_word.stats_text(content,20)
1512

1613
#d12_training不要用到
1714
#import getpass

0 commit comments

Comments
 (0)