Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
240 commits
Select commit Hold shift + click to select a range
221c42a
day4任务
evlyn5 Jul 11, 2019
9c353bd
Merge branch 'master' of https://github.com/evlyn5/selfteaching-pytho…
evlyn5 Jul 11, 2019
35b7781
DAY5 任务
evlyn5 Jul 15, 2019
445abb0
Merge branch 'master' into master
yingca1 Jul 15, 2019
96d595e
day6
evlyn5 Jul 23, 2019
6543144
Merge branch 'master' of https://github.com/evlyn5/selfteaching-pytho…
evlyn5 Jul 23, 2019
0aab6f4
Merge branch 'master' into master
yingca1 Jul 23, 2019
8ab4d04
Delete fs.py
yingca1 Jul 23, 2019
3084b73
Create 1001S02E06_stats_word.py
studyharder-guoguo Aug 2, 2019
7edfb9e
day7
bubu8yuanmin Aug 4, 2019
f6532ea
day7 v2
bubu8yuanmin Aug 4, 2019
ef447ce
d08
Zezhou-Sun Aug 9, 2019
f75ddf1
【1901100146】day08作业心得
xiatian123-web Aug 9, 2019
53a6a37
Create 1001S02E04_control_flow.py
wang-yulin Aug 16, 2019
83c110e
【190100146】自学训练营17群d09作业
xiatian123-web Aug 16, 2019
0c3f962
d09
Zezhou-Sun Aug 18, 2019
4f67a18
Update main.py
Zezhou-Sun Aug 19, 2019
dccc35c
Update stats_word.py
Zezhou-Sun Aug 19, 2019
eea6624
Create QR.png
chengfeng195 Aug 21, 2019
0e3539f
【1901100297】自学训练营学习20群 DAY3 (#5622)
vivian6152 Aug 23, 2019
83805e0
自学训练营学习3群 1901040056 DAY 11 (#5628)
chunsmile Aug 23, 2019
50da761
[1901010103]自学训练营学习1群 Day8-10 (#5626)
internetrat7788 Aug 23, 2019
a2f8c13
day6 1901100053 (#5619)
boy-35 Aug 23, 2019
44d57fc
【1901100023】自学训练营学习13群 DAY6 (#5627)
yitingyyiting Aug 23, 2019
aeb1a97
create two files (#5624)
oli9 Aug 23, 2019
2b650e4
创建了两个文件夹 (#5623)
rtgong Aug 23, 2019
b3deca8
自学训练营学习19群 -【1901100279】- Day 1 (#5620)
raincy811 Aug 23, 2019
4458814
【1901100303】自学训练营学习20群 day2 (#5631)
python-yuanweiyu Aug 23, 2019
7388ed8
1901100251自学训练营学习19群DAY4 (#5632)
bennymoqin Aug 23, 2019
3596c7e
自学训练营学习19群-【1901100279】- Day2 (#5633)
raincy811 Aug 23, 2019
396df1f
Create main.py
chengfeng195 Aug 23, 2019
27956a4
Create stats_word.py
chengfeng195 Aug 23, 2019
8470c89
Create stats.png
chengfeng195 Aug 23, 2019
93b93d0
Create tang300.json
chengfeng195 Aug 23, 2019
8a3b748
Update QR.png
chengfeng195 Aug 23, 2019
686a405
Merge pull request #5634 from chengfeng195/master
XINGRUFANG Aug 23, 2019
270b25c
[1901100246]自学训练营010期连续班 陈春第8课作业提交 (#5559)
chenchun87 Aug 23, 2019
76b7e7b
1001S02E02_hello_python.py
281504271 Aug 23, 2019
1966ad9
Merge pull request #5636 from 281504271/master
XINGRUFANG Aug 23, 2019
b667fcc
【1901100277】自学训练营19群 Day 7 (#5638)
xuefeng365 Aug 23, 2019
fba9d71
自学训练营20群 1901100298 day5 (#5639)
mydesire876 Aug 23, 2019
b56fd4a
【190100146】自学训练营学习17群day10作业
xiatian123-web Aug 23, 2019
82b7fe9
【1901100146】自学训练营17群d10感悟
xiatian123-web Aug 23, 2019
13f1b5a
Update README.md
AmazingJulie Aug 23, 2019
f19434b
Merge pull request #5641 from AmazingJulie/master
XINGRUFANG Aug 23, 2019
d0f99ae
Create main.py
wanghui333 Aug 23, 2019
22c7a93
Create stats_word.py
wanghui333 Aug 23, 2019
69a788c
Merge pull request #5642 from wanghui333/master
XINGRUFANG Aug 23, 2019
3f7721e
day5 study
wang-yulin Aug 23, 2019
50bb342
【1901100351】自学训练营20群 Day 02 (#5645)
rtgong Aug 23, 2019
c37351a
自学训练营学习20群+1901110099+day2的作业 (#5649)
oli9 Aug 23, 2019
21d8d0d
【1901100247】自学训练营 DAY4 (#5646)
WGL1 Aug 23, 2019
e85a875
day09
eaebymomo Aug 23, 2019
eedf42d
day 11
CHJ219 Aug 23, 2019
dabc0a6
day 09
eaebymomo Aug 24, 2019
f257938
day 10
eaebymomo Aug 24, 2019
70ab9a8
自学训练营学习19群 1901100271 Day7 (#5651)
noodleCYF Aug 24, 2019
c8b2c1f
1901100283 自学训练营学习19群 Day6 (#5654)
PerryZ10 Aug 24, 2019
0461842
自学19-1901100264-d3 (#5650)
JINGJING-LI-arch Aug 24, 2019
39555b8
自学训练营学习20 DAY4 (#5656)
zerasq Aug 24, 2019
5bcf809
【1901100050】自学训练营学习13群 DAY8 (#5657)
lisq2018 Aug 24, 2019
0749f19
自学训练营学习1群-1901010134-D09 (#5658)
samele0077 Aug 24, 2019
9ce64eb
【1901100066】⾃学训练营14群 DAY10 (#5660)
HenrySong000 Aug 24, 2019
240751a
【1901100023】自学训练营学习13群 DAY07 (#5661)
yitingyyiting Aug 24, 2019
d10c4ee
Merge pull request #5653 from CHJ219/master
XINGRUFANG Aug 24, 2019
170f6ce
d09修改
eaebymomo Aug 24, 2019
40a6425
d10
Zezhou-Sun Aug 24, 2019
beb473b
Merge pull request #5644 from wangyulinaaron/master
XINGRUFANG Aug 24, 2019
5b35f74
【1901010161】自学训练营学习2群 Day10 ##5516 (#5662)
liujiayi0042 Aug 24, 2019
119d7c7
Merge branch 'master' into master
XINGRUFANG Aug 24, 2019
cd3deb4
Merge pull request #5640 from xiatian123-web/master
XINGRUFANG Aug 24, 2019
1b5c6df
Merge pull request #5652 from eaebymomo/master
XINGRUFANG Aug 24, 2019
da25eab
day11 请教练帮我看看问题在哪里
eaebymomo Aug 24, 2019
eee454e
day7
studyharder-guoguo Aug 24, 2019
72b3259
Merge pull request #5667 from studyharder-guoguo/master
XINGRUFANG Aug 25, 2019
7accc44
DAY11作业
eaebymomo Aug 25, 2019
80a21ea
Merge pull request #5666 from eaebymomo/master
XINGRUFANG Aug 25, 2019
0692c2f
1901100249 自学训练营学习19群 day02 (#5670)
shuwei-chen Aug 25, 2019
39c72de
自学训练营学习19群 1901100284 Day3作业 (#5669)
jinmeiH Aug 25, 2019
d00800a
【1901100023】自学训练营学习13群 DAY08 (#5671)
yitingyyiting Aug 25, 2019
4d690fb
自学训练营学习1群+1901010109+day8 (#5668)
idongye Aug 25, 2019
2675102
自学训练营20群 1901100298 day6 (#5665)
mydesire876 Aug 25, 2019
7e9ea23
190110304自学训练营学习20群day4 (#5663)
xing-cheng Aug 25, 2019
06f52c8
自学训练营学习3群 1901040056 DAY12 (#5674)
chunsmile Aug 25, 2019
10e205f
1901100350自学训练营学习群day3 new (#5673)
myzonecn Aug 25, 2019
1421f5c
1901100351【自学训练营20】day03 (#5676)
rtgong Aug 25, 2019
2e1ec78
1901100300自学训练营学习20群day2 (#5672)
lgxwyn Aug 25, 2019
75eae97
day7 任务
evlyn5 Aug 25, 2019
7d705e3
Merge branch 'master' of https://github.com/evlyn5/selfteaching-pytho…
evlyn5 Aug 25, 2019
256a933
第一个.py文件
Blue-three Aug 25, 2019
7abfd3d
DAY12和DAY13
eaebymomo Aug 25, 2019
c2c168c
DAY10
a382064574 Aug 25, 2019
fd0c6bf
Merge pull request #5683 from a382064574/master
XINGRUFANG Aug 26, 2019
fe62d74
Merge pull request #5682 from eaebymomo/master
XINGRUFANG Aug 26, 2019
33470d2
Merge pull request #5679 from Blue-three/master
XINGRUFANG Aug 26, 2019
294b23f
Delete main.py
liujiayi0042 Aug 26, 2019
f3427ac
Delete stats_word.py
liujiayi0042 Aug 26, 2019
fd20900
自学19群 1901100264 d4 work (#5685)
JINGJING-LI-arch Aug 26, 2019
441fc2a
【1901100354】自学训练营学习20群 day1 (#5687)
lionel-ate Aug 26, 2019
e498cce
d8 更正 (#5688)
samele0077 Aug 26, 2019
af50fa1
【1901100244】自学训练营学习20群 Day 06 (#5681)
shen-huang Aug 26, 2019
8482569
自学训练营学习5群 Day12 (#5684)
williswill Aug 26, 2019
2c9ea1c
Day13
Nanananashi Aug 26, 2019
81fe546
Delete 1901100264.txt
liujiayi0042 Aug 26, 2019
3ff8f3f
1
liyiming12 Aug 26, 2019
cc01b07
d07任务更新
evlyn5 Aug 26, 2019
bff34b9
Merge branch 'master' into master
XINGRUFANG Aug 26, 2019
d5439cd
Merge pull request #5692 from evlyn5/master
XINGRUFANG Aug 26, 2019
1418195
Merge pull request #5691 from liyiming12/master
XINGRUFANG Aug 26, 2019
c89c67a
Merge pull request #5690 from Nanananashi/master
XINGRUFANG Aug 26, 2019
38a31de
第三天作业 请查收 14群 1901100061 (#5689)
leilongquan Aug 26, 2019
83041cb
day7 1901100053 (#5696)
boy-35 Aug 26, 2019
28d1183
04
huangmengzhu Aug 26, 2019
683a836
d12
CHJ219 Aug 26, 2019
6b622b5
Update main.py
CHJ219 Aug 26, 2019
33b2f1b
Update readme.md
chengfeng195 Aug 27, 2019
0c08fa1
Merge pull request #5710 from chengfeng195/master
XINGRUFANG Aug 27, 2019
1bb33fa
【1901110099】⾃自学训练营20群 DAY3 (#5700)
oli9 Aug 27, 2019
0922f68
【1901100354】自学训练营学习20群 DAY2 (#5698)
lionel-ate Aug 27, 2019
bcac574
【1901100351】自学训练营20 Day4 (#5702)
rtgong Aug 27, 2019
1d65c15
屠龙飞—自学训练营1-Day 4 (#5704)
longfei-tu Aug 27, 2019
f377ac6
Update main.py
CHJ219 Aug 27, 2019
1b915ba
1901100283 自学训练营学习19群 Day7 (#5708)
PerryZ10 Aug 27, 2019
3e5f2a6
Merge pull request #5707 from CHJ219/master
XINGRUFANG Aug 27, 2019
380e3b0
自学训练营学习3群 1901040056 DAY 13 (#5709)
chunsmile Aug 27, 2019
11a1aa0
[1901010103]自学训练营学习1群 Day12 (#5705)
internetrat7788 Aug 27, 2019
9283741
【1901100081】⾃学训练营学习15群 DAY10
alirezamahboobi Aug 27, 2019
5be5566
DAY6
a136161 Aug 27, 2019
861d8ce
Create 1001S02E03_calculator.py
PassionPit Aug 27, 2019
a58350d
Merge pull request #5715 from PassionPit/master
XINGRUFANG Aug 27, 2019
0f7c1fd
Merge pull request #5713 from yaodadada/master
XINGRUFANG Aug 27, 2019
a16fc1a
1901100350自学训练营20群day4 (#5716)
myzonecn Aug 27, 2019
4a66834
自学训练营20群 1901100298 day7 (#5711)
mydesire876 Aug 27, 2019
106f409
Delete workspace.xml
Wenyuhua1 Aug 27, 2019
4a49356
自学训练营学习20群DAT5 (#5718)
zerasq Aug 27, 2019
d8b1cf8
Create 1001S02E04_control_flow.py
PassionPit Aug 27, 2019
2ab1aed
day6 修改
a136161 Aug 27, 2019
74b48dc
自学训练营14群 1901100064 day10 (#5719)
lishuaizzu Aug 27, 2019
6382863
first home work
tony-hello Aug 27, 2019
42686e1
Merge pull request #5714 from a136161/master
XINGRUFANG Aug 27, 2019
35e4df4
Merge pull request #5725 from tony-hello/master
XINGRUFANG Aug 27, 2019
a2ef6c2
自学训练营20群 1901100298 (#5722)
mydesire876 Aug 27, 2019
6bdc6d2
【1901100303】自学训练营学习20群 day3 (#5721)
python-yuanweiyu Aug 27, 2019
c14864e
自学训练营学习5群 Day13 (#5724)
williswill Aug 27, 2019
8d7d3d6
自学训练营学习19群-1901100254-day3 (#5726)
JF-RZ Aug 27, 2019
079a15f
Merge pull request #5720 from PassionPit/master
XINGRUFANG Aug 27, 2019
c596235
20群-1901100305-day2作业 (#5728)
ningJZY Aug 27, 2019
8c3e1bb
Create 1001S02E02_hello_python.py
tony-hello Aug 27, 2019
28c49a0
Create README.md
eaebymomo Aug 27, 2019
feb5748
Create 1001S02E06_stats_word.py
wang-yulin Aug 27, 2019
b21a745
1901100042-自学训练营学习13群-DAY8异常处理 (#5731)
Taskow Aug 28, 2019
f364b63
1901100283 自学训练营学习19群 Day8 (#5732)
PerryZ10 Aug 28, 2019
a919912
Merge pull request #5729 from tony-hello/master
XINGRUFANG Aug 28, 2019
f80f421
text+word
sand-web Aug 28, 2019
f31809a
Merge pull request #5737 from sand-web/master
XINGRUFANG Aug 28, 2019
564bc1f
自学训练营自学3 群 1901040056 DAY14 (#5734)
chunsmile Aug 28, 2019
80215b9
Merge pull request #5733 from wangyulinaaron/master
XINGRUFANG Aug 28, 2019
1bd466a
Merge pull request #5701 from huangmengzhu/master
XINGRUFANG Aug 28, 2019
1f6c6d8
Merge pull request #5730 from eaebymomo/master
XINGRUFANG Aug 28, 2019
4a41a7e
1901100300自学训练营学习20群day3 (#5738)
lgxwyn Aug 28, 2019
ae2cc41
【1901100146】自学训练营学习17群d11作业
xiatian123-web Aug 28, 2019
4963c44
Merge pull request #5739 from xiatian123-web/master
XINGRUFANG Aug 28, 2019
80107cc
【1901100146】自学训练营学习17群d12作业
xiatian123-web Aug 28, 2019
af1307a
Summary Day 01
North-Sea-999 Aug 28, 2019
1b8b273
Merge pull request #5741 from North-Sea-999/master
XINGRUFANG Aug 28, 2019
7af4ece
自学训练营学习19群+1901100240+Day10的作业 (#5742)
Ningziyun Aug 28, 2019
0bea441
Create 1001S02E01_helloworld.txt
15225459445 Aug 28, 2019
1213d9a
Create readme.md
15225459445 Aug 28, 2019
302f624
第二提交
15225459445 Aug 28, 2019
755d944
Create 1001S02E05_string.py
PassionPit Aug 28, 2019
dd57f0f
Create 1001S02E05_stats_text.py
PassionPit Aug 28, 2019
edd1a7f
Create 1001S02E05_array.py
PassionPit Aug 28, 2019
f0ab601
Merge pull request #5744 from 15225459445/master
XINGRUFANG Aug 28, 2019
78848bd
Merge pull request #5743 from PassionPit/master
XINGRUFANG Aug 28, 2019
1c48e3e
Merge pull request #5740 from xiatian123-web/master
XINGRUFANG Aug 28, 2019
865d3be
day 7 v3
bubu8yuanmin Aug 28, 2019
08958ea
【1901100231】自学训练营学习18群-Day 13
CHJ219 Aug 28, 2019
f865744
Merge pull request #5748 from bubu8yuanmin/master
XINGRUFANG Aug 29, 2019
4edc025
[1901100303]自学训练营学习20群 day4 (#5746)
python-yuanweiyu Aug 29, 2019
c6e96d0
Merge pull request #5749 from CHJ219/master
XINGRUFANG Aug 29, 2019
cd91d11
day9 1901100053 (#5745)
boy-35 Aug 29, 2019
c482fd1
自学训练营学习13群+1901100192+day2作业! (#5750)
lyq760208 Aug 29, 2019
674881c
caculator
tony-hello Aug 29, 2019
fe180fc
The first commit (#5751)
nxreo Aug 29, 2019
d7e7db8
Create 1001S02E06_stats_word.py
PassionPit Aug 29, 2019
f572f61
Merge pull request #5753 from tony-hello/master
XINGRUFANG Aug 29, 2019
eea1675
Merge pull request #5752 from PassionPit/master
XINGRUFANG Aug 29, 2019
c329104
Create stats_word.py
PassionPit Aug 29, 2019
c51afcb
Create main.py
PassionPit Aug 29, 2019
e9b1cdc
Merge pull request #5754 from PassionPit/master
XINGRUFANG Aug 29, 2019
72c978f
Update README.md
CHJ219 Aug 29, 2019
6af1bbe
Merge pull request #5755 from CHJ219/master
XINGRUFANG Aug 29, 2019
8aa8dbc
自学训练营学习19群+1901100240+Day11的作业 (#5756)
Ningziyun Aug 29, 2019
6b4cbce
Create 1001S02E04_control_flow.py
tony-hello Aug 29, 2019
2dcf142
Merge pull request #5757 from tony-hello/master
XINGRUFANG Aug 29, 2019
f7f1bd4
Create stats_word.py
PassionPit Aug 29, 2019
f2e8ef2
Create main.py
PassionPit Aug 29, 2019
8d5f543
Merge pull request #5758 from PassionPit/master
XINGRUFANG Aug 29, 2019
e05e707
day1 (#5759)
superjmm Aug 29, 2019
8f5fab2
DAY6 (#5760)
zerasq Aug 29, 2019
e0905b3
(1901100191)自学训练营学习13群对day1 (#5762)
xiaooyu Aug 29, 2019
abfa864
Create stats_word.py
PassionPit Aug 29, 2019
fb86620
Create main.py
PassionPit Aug 29, 2019
901ba0d
Merge pull request #5763 from PassionPit/master
XINGRUFANG Aug 29, 2019
187f259
modele learning
wang-yulin Aug 29, 2019
2fad751
Merge pull request #5766 from wangyulinaaron/master
XINGRUFANG Aug 29, 2019
dbba354
text
sand-web Aug 29, 2019
ed1a055
自学训练营学习19群+1901100240+Day12的作业 (#5761)
Ningziyun Aug 30, 2019
f77d051
1901100296 自学训练营学习20群 DAY2 (#5768)
superjmm Aug 30, 2019
5477b72
day10 1901100053 (#5765)
boy-35 Aug 30, 2019
62ca357
19011000 day1 work
ranbobo Aug 30, 2019
a8ca01e
Merge pull request #5769 from ranbobo/master
XINGRUFANG Aug 30, 2019
6b660d4
Create main.py
PassionPit Aug 30, 2019
428229f
Create stats_word.py
PassionPit Aug 30, 2019
17a457b
Merge pull request #5770 from PassionPit/master
XINGRUFANG Aug 30, 2019
7c97ae7
Merge pull request #5767 from sand-web/master
XINGRUFANG Aug 30, 2019
982d7c7
自学训练营学习19群+1901100240+Day13的作业 (#5771)
Ningziyun Aug 30, 2019
910d2a3
day05
tony-hello Aug 30, 2019
c58bd81
Merge pull request #5772 from tony-hello/master
XINGRUFANG Aug 30, 2019
f768c6f
Create stats_word.py
PassionPit Aug 30, 2019
c2f3a36
Create main.py
PassionPit Aug 30, 2019
d7cc0d4
Update main.py
PassionPit Aug 30, 2019
2b2e961
Merge pull request #5774 from PassionPit/master
XINGRUFANG Aug 30, 2019
b45e4b7
自学训练营学习19群+1901100240+Day14的作业 (#5773)
Ningziyun Aug 30, 2019
cb0bf79
Create 1001S02E02_hello_python.py
15225459445 Aug 30, 2019
9b5c02a
Create stats_word.py
PassionPit Aug 30, 2019
e5fd7c7
Create main.py
PassionPit Aug 30, 2019
36a5fb1
Merge pull request #5776 from 15225459445/master
XINGRUFANG Aug 30, 2019
c9a62f1
Create main.py
wanghui333 Aug 30, 2019
dc734d0
Create stats_word.py
wanghui333 Aug 30, 2019
bb2f75b
Merge pull request #5778 from wanghui333/master
XINGRUFANG Aug 30, 2019
3af4cd6
1901100255 (#5779)
sujianjin30 Aug 30, 2019
a8d675a
Merge pull request #5780 from PassionPit/master
XINGRUFANG Aug 30, 2019
6c4d87b
Create stats_word.py
PassionPit Aug 30, 2019
74a2a70
Create main.py
PassionPit Aug 30, 2019
16fdb51
Update stats_word.py
PassionPit Aug 30, 2019
97e68a5
Update main.py
PassionPit Aug 30, 2019
a2d117b
Update stats_word.py
PassionPit Aug 30, 2019
6d43ade
Update stats_word.py
PassionPit Aug 30, 2019
8e7555d
Merge pull request #5782 from PassionPit/master
XINGRUFANG Aug 30, 2019
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
36 changes: 36 additions & 0 deletions exercises/1901010103/d11/mymodule/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/python
import yagmail
import requests
import getpass
import sys
from pyquery import PyQuery
sys.path.append('/Users/Yang/GitHub:PJ1/selfteaching-python-camp/exercises/1901010120/d11/mymodule/')
from stats_word import stats_text
from os import path

#提取微信地址和正文
content_url = "https://mp.weixin.qq.com/s/pLmuGoc4bZrMNl7MSoWgiA"
html_code = requests.get(content_url).text
document = PyQuery(html_code)
content = document("#js_content").text().replace("\n", "")


#file_path = path.join(path.dirname(path.abspath(__file__)),'./tang300.json')
#with open(file_path,'r', encoding="utf-8") as f_poems:
# poems_json = json.load(f_poems)

#all_poems = ""
#for poems_info in poems_json:
# all_poems += poems_info["contents"]

try:
en_result, cn_result = stats_text("",content)
#print cn_result
smtp_host = "smtp.sina.com"
sender = input("Please enter the sender's email address: ")
password = getpass.getpass("Please enter the sender's email password: ")
recipient = input("Please enter the recipient's email address: ")
yagmail.SMTP(user=sender, password=password, host=smtp_host).send(recipient, "Cutted words", str(cn_result))
except ValueError as e:
print("Exception catched.")
print(e)
46 changes: 46 additions & 0 deletions exercises/1901010103/d11/mymodule/stats_word.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/usr/bin/python

import string
import jieba
from collections import Counter

def stats_text_en(en_text):
if not isinstance(en_text, str):
raise ValueError("The method only accepts type str.")

for en_special_word in string.punctuation:
if en_special_word in en_text:
en_text = en_text.replace(en_special_word, "")

en_word_counter = Counter()
en_text = en_text.split()
for en_word in en_text:
en_word_counter[en_word] += 1

return en_word_counter.most_common()


def stats_text_cn(cn_text):
if not isinstance(cn_text, str):
raise ValueError("The method only accepts type str.")

cn_special_words = "!“”#$%&‘’()*+,-。/:;、……<=>?@[]「」《》^_`{|}~\n"
for cn_special_word in cn_special_words:
if cn_special_word in cn_text:
cn_text = cn_text.replace(cn_special_word, "")

#把字符串给cut作为第一个参数
cn_text = jieba.cut(cn_text, cut_all=False)

cn_word_counter = Counter()
for cn_word in cn_text:
cn_word_counter[cn_word] += 1

return cn_word_counter.most_common(100)


def stats_text(en_text, cn_text):
if (not isinstance(en_text, str)) or (not isinstance(cn_text, str)):
raise ValueError("The method only accepts type str.")

return stats_text_en(en_text), stats_text_cn(cn_text)
29 changes: 29 additions & 0 deletions exercises/1901010103/d12/mymodule/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# coding=utf8
#!/usr/bin/python
from wxpy import *
import sys
from pyquery import PyQuery
sys.path.append('/Users/Yang/GitHub:PJ1/selfteaching-python-camp/exercises/1901010120/d11/mymodule/')
from stats_word import stats_text
from os import path

#注册机器人
wechat_bot = Bot()
#注册内容是分享就抽取
@wechat_bot.register(chats=User, msg_types=SHARING)
def process_url(msg):
content_url = msg.url
html_code = requests.get(content_url).text
document = PyQuery(html_code)
content = document("#js_content").text().replace("\n", "")

try:
en_result, cn_result = stats_text("", content)
# print(cn_result)
msg.reply(cn_result)

except ValueError as e:
print("Exception catched.")
print(e)

embed()
45 changes: 45 additions & 0 deletions exercises/1901010103/d12/mymodule/stats_word.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/usr/bin/python

import string
import jieba
from collections import Counter

def stats_text_en(en_text):
if not isinstance(en_text, str):
raise ValueError("The method only accepts type str.")

for en_special_word in string.punctuation:
if en_special_word in en_text:
en_text = en_text.replace(en_special_word, "")

en_word_counter = Counter()
en_text = en_text.split()
for en_word in en_text:
en_word_counter[en_word] += 1

return en_word_counter.most_common(100)


def stats_text_cn(cn_text):
if not isinstance(cn_text, str):
raise ValueError("The method only accepts type str.")

cn_special_words = "!“”#$%&‘’()*+,-。/:;、……<=>?@[]「」《》^_`{|}~\n"
for cn_special_word in cn_special_words:
if cn_special_word in cn_text:
cn_text = cn_text.replace(cn_special_word, "")

cn_text = jieba.cut(cn_text, cut_all=False)

cn_word_counter = Counter()
for cn_word in cn_text:
cn_word_counter[cn_word] += 1

return cn_word_counter.most_common(100)


def stats_text(en_text, cn_text):
if (not isinstance(en_text, str)) or (not isinstance(cn_text, str)):
raise ValueError("The method only accepts type str.")

return stats_text_en(en_text), stats_text_cn(cn_text)
3 changes: 3 additions & 0 deletions exercises/1901010109/codetest.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
"folders": [
{
"path": "."
},
{
"path": "D:\\myPython\\Future"
}
]
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from IPython.core.interactiveshell import InteractiveShell
InteractiveShell.ast_node_interactivity = 'all'

from stats_word import stats_text
from mymodule import stats_word

text = '''
愚公移⼭
Expand Down Expand Up @@ -83,6 +83,6 @@
two mighty gods to carry the mountains away.
'''

print( f"text 里各英文单词和各中文汉字出现的次数,降序排列:", stats_text(text) )
for key,value in stats_text(text) :
print( f"text 里各英文单词和各中文汉字出现的次数,降序排列:", stats_word.stats_text(text) )
for key,value in stats_word.stats_text(text) :
print( key, value )
91 changes: 91 additions & 0 deletions exercises/1901010109/d08/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
from IPython.core.interactiveshell import InteractiveShell
InteractiveShell.ast_node_interactivity = 'all'

from mymodule import stats_word

text = '''
愚公移⼭

太⾏,王屋⼆⼭的北⾯,住了⼀個九⼗歲的⽼翁,名叫愚公。⼆⼭佔地廣闊,擋住去路,使他
和家⼈往來極為不便。

⼀天,愚公召集家⼈說:「讓我們各盡其⼒,剷平⼆⼭,開條道路,直通豫州,你們認為怎
樣?」
⼤家都異⼝同聲贊成,只有他的妻⼦表示懷疑,並說:「你連開鑿⼀個⼩丘的⼒量都沒有,怎
可能剷平太⾏、王屋⼆⼭呢?況且,鑿出的⼟⽯⼜丟到哪裏去呢?」

⼤家都熱烈地說:「把⼟⽯丟進渤海裏。」
於是愚公就和兒孫,⼀起開挖⼟,把⼟⽯搬運到渤海去。
愚公的鄰居是個寡婦,有個兒⼦⼋歲也興致勃勃地⾛來幫忙。
寒來暑往,他們要⼀年才能往返渤海⼀次。

住在⿈河河畔的智叟,看⾒他們這樣⾟苦,取笑愚公說:「你不是很愚蠢嗎?你已⼀把年紀
了,就是⽤盡你的氣⼒,也不能挖去⼭的⼀⻆呢?」

愚公歎息道:「你有這樣的成⾒,是不會明⽩的。你⽐那寡婦的⼩兒⼦還不如呢!就算我死
了,還有我的兒⼦,我的孫⼦,我的曾孫⼦,他們⼀直傳下去。⽽這⼆⼭是不會加⼤的,總有
⼀天,我們會把它們剷平。」

智叟聽了,無話可說:
⼆⼭的守護神被愚公的堅毅精神嚇倒,便把此事奏知天帝。天帝佩服愚公的精神,就命兩位⼤
⼒神揹⾛⼆⼭。

How The Foolish Old Man Moved Mountains

Yugong was a ninety-year-old man who lived at the north of two high
mountains, Mount Taixing and Mount Wangwu.


Stretching over a wide expanse of land, the mountains blocked
yugong’s way making it inconvenient for him and his family to get
around.
One day yugong gathered his family together and said,”Let’s do our
best to level these two mountains. We shall open a road that leads
to Yuzhou. What do you think?”

All but his wife agreed with him.
“You don’t have the strength to cut even a small mound,” muttered
his wife. “How on earth do you suppose you can level Mount Taixin
and Mount Wanwu? Moreover, where will all the earth and rubble go?”
“Dump them into the Sea of Bohai!” said everyone.

So Yugong, his sons, and his grandsons started to break up rocks and
remove the earth. They transported the earth and rubble to the Sea
of Bohai.

Now Yugong’s neighbour was a widow who had an only child eight years
old. Evening the young boy offered his help eagerly.

Summer went by and winter came. It took Yugong and his crew a full
year to travel back and forth once.

On the bank of the Yellow River dwelled an old man much respected
for his wisdom. When he saw their back-breaking labour, he ridiculed
Yugong saying,”Aren’t you foolish, my friend? You are very old now,
and with whatever remains of your waning strength, you won’t be able
to remove even a corner of the mountain.”

Yugong uttered a sigh and said,”A biased person like you will never
understand. You can’t even compare with the widow’s little boy!”

“Even if I were dead, there will still be my children, my
grandchildren, my great grandchildren, my great great grandchildren.
They descendants will go on forever. But these mountains will not
grow any taler. We shall level them one day!” he declared with
confidence.

The wise old man was totally silenced.
When the guardian gods of the mountains saw how determined Yugong
and his crew were, they were struck with fear and reported the
incident to the Emperor of Heavens.

Filled with admiration for Yugong, the Emperor of Heavens ordered
two mighty gods to carry the mountains away.
'''

try:
print( f"text 里各英文单词和各中文汉字出现的次数,降序排列:", stats_word.stats_text(text) )
for key,value in stats_word.stats_text(text) :
print( key, value )
except ValueError:
print( "输入的不是文本,请重新输入" )
Loading