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
17 changes: 16 additions & 1 deletion exercises/1901010132/README.md
Original file line number Diff line number Diff line change
@@ -1 +1,16 @@
1
自学编程训练营总结

自学编程训练营学习内容即将结束了,从最初的抓耳挠腮到现在的熟练应对,当中经历了无数个自我否打与自我鞭策,所谓念念不忘必有回响,只要坚持都会有痕迹留下,当痕迹足够多时离开花结果就不远了。

整个学习过程中电脑硬盘问题使系统崩溃了3次,这3次错误差点让我无法继续下去,每一次安装都出现了各种各样的问题,第一次是GitHub Desktop重装Commit failed错误,使用搜索引擎修改config文件解决。另外还碰上了作业clone本地出现fatal: the remote end hung up unexpectedly错误,切换为手机4G网络给解决了。最后一个写完代码调试的时候出现属性“program”不存在错误 ,这个错误至今未能解决,最后没办法借了台电脑完成最后的作业。

刚开始报名训练营时我正值数据分析课程助教带班期间,同时公司事务繁多连续加班,感觉自己跟陀螺一样拼命转,每天下班回来就争分夺秒的开电脑。之后又碰到商业分析课的开班,一度学习终止。现在回头看,这些困难都挺过来了,带班的数据分析课学员大部分以优异的成绩毕业,自己参与的商业分析课程也已经获得优秀毕业,现在编程训练营的课程也即将结束了。当经历了各种困难解决之后回过来看,都是满满的成就感,虽然当时被困难折磨的死去活来,觉得随时可能完蛋。在这里想说一句,这种感觉真好。

先完成再完美,不能困在问题当中出不来,虽然钻研精神也很重要,但一味的困在一个问题当中,会严重的损失效率,进一步的给自己带来挫败感。一定要给自己一个时间,时间到了之后不管问题有没有解决,暂时搁置问题并且记录下来,然后把学习进度向前推进,去学习其他内容,随着知识容量的扩大和知识点的贯通,可能之前的问题在后面来看已经不是问题了。

学习一项新技能其实不难,有时候你之所以觉得难,是因为你在远远的看,而没有让自己身处其中。就拿编程来说,以前的一行行代码摆在自己面前绝对是跟天书一样,现在可能还是跟天书一样,但现在不同的是我可以很自信的对自己说,我可以把他搞懂。拥有自学能力的人就是拥有这种底气。

现在每天都在学习新的东西。自从进了笑来老师的践行群,每天的学习根本停不下来。笑来老师和其他老师天天在群里讲课,只能说这2019.74元的入群费太值了。目前python只算是入门,接下来会继续学习践行群里李俊老师的编程课。如果有在践行群里的同学欢迎加我微信hello-say一起交流。


最后要感谢助教大大们和糖总,给予了我很多帮助和鼓励!
9 changes: 9 additions & 0 deletions exercises/1901010132/day10/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from mymodule import stats_word
import json

with open(r'\Users\Administrator\Documents\GitHub\selfteaching-python-camp\exercises\1901010132\day10\tang300.json',encoding='UTF-8') as f:
read_date = f.read()
try:
print('统计前20的词频数: \n',stats_word.stats_text_cn(read_date,20))
except ValueError as e:
print(e)
50 changes: 50 additions & 0 deletions exercises/1901010132/day10/mymodule/stats_word.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
text= '''
"Her eyes beginning to water, she went on,
"So I would like you all to make me a promise:
from now on, on your way to school,
or on your way home, find something beautiful
to notice. It doesn' t have to be something you
see -it could be a scent perhaps of freshly
baked bread wafting out of someone 's house,
or it could be the sound of the breeze
slightly rustling the leaves in the trees,
or the way the morning light catches one
autumn leaf as it falls gently to the ground.
Please, look for these things, and remember them."
  她的眼睛开始湿润了,她接着说因此我想让你们每个人答应我:
从今以后,在你上学或者放学的路上,要发现一些美丽的事物。
它不一定是你看到的某个东西——它可能是一种香味——
也许是新鲜烤面包的味道从某一座房里飘出来,也许是微风轻拂树叶的声音,
或者是晨光照射在轻轻飘落的秋叶上的方式。请你们寻找这些东西并且记住它们吧。
'''
import re
import collections
import jieba #结巴中文分词
count=int()
def stats_text_en(text,count):
if type(text) == str:
b=re.sub(r'[^A-Za-z]',' ',text)
list1=b.split()
return(collections.Counter(list1).most_common(count))
else:
raise ValueError('文本为非字符串')

def stats_text_cn(text,count):
if not isinstance(text,str):
raise ValueError('文本为非字符串')
p=re.compile(u'[\u4e00-\u9fa5]')
a=re.findall(p,text)
str2=''.join(a)
seg_list = jieba.cut(str2,cut_all=False) #jieba.cut返回的结构是一个可迭代的生成器generator
newlist=[]
for i in seg_list:
if len(i) >= 2:
newlist.append(i)
return(collections.Counter(newlist).most_common(count))

def stats_text(text,count):
if not isinstance(text,str):
raise ValueError('文本为非字符串')
stats_text_cn(text,count)
stats_text_en(text,count)
stats_text(text,count)
21 changes: 21 additions & 0 deletions exercises/1901010132/day12/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import requests
from pyquery import PyQuery
from mymodule import stats_word
from wxpy import Bot,Message,embed
#初始化机器人,扫码登陆
bot = Bot()
#找到好友
my_friend = bot.friends().search('PrincessAKing')[0]
#发送文本给好友
my_friend.send('分享任意微信文章给我')
#监听消息
#回复my_friend的消息
@bot.register(my_friend)
def reply_my_friend(msg):
if msg.type == 'Sharing':
response = requests.get(msg.url)
document = PyQuery(response.text)
content = document('#js_content').text()
reply = stats_word.stats_text_cn(content,100)
return reply
embed()
50 changes: 50 additions & 0 deletions exercises/1901010132/day12/mymodule/stats_word.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
text= '''
"Her eyes beginning to water, she went on,
"So I would like you all to make me a promise:
from now on, on your way to school,
or on your way home, find something beautiful
to notice. It doesn' t have to be something you
see -it could be a scent perhaps of freshly
baked bread wafting out of someone 's house,
or it could be the sound of the breeze
slightly rustling the leaves in the trees,
or the way the morning light catches one
autumn leaf as it falls gently to the ground.
Please, look for these things, and remember them."
  她的眼睛开始湿润了,她接着说因此我想让你们每个人答应我:
从今以后,在你上学或者放学的路上,要发现一些美丽的事物。
它不一定是你看到的某个东西——它可能是一种香味——
也许是新鲜烤面包的味道从某一座房里飘出来,也许是微风轻拂树叶的声音,
或者是晨光照射在轻轻飘落的秋叶上的方式。请你们寻找这些东西并且记住它们吧。
'''
import re
import collections
import jieba #结巴中文分词
count=int()
def stats_text_en(text,count):
if type(text) == str:
b=re.sub(r'[^A-Za-z]',' ',text)
list1=b.split()
return(collections.Counter(list1).most_common(count))
else:
raise ValueError('文本为非字符串')

def stats_text_cn(text,count):
if not isinstance(text,str):
raise ValueError('文本为非字符串')
p=re.compile(u'[\u4e00-\u9fa5]')
a=re.findall(p,text)
str2=''.join(a)
seg_list = jieba.cut(str2,cut_all=False) #jieba.cut返回的结构是一个可迭代的生成器generator
newlist=[]
for i in seg_list:
if len(i) >= 2:
newlist.append(i)
return(collections.Counter(newlist).most_common(count))

def stats_text(text,count):
if not isinstance(text,str):
raise ValueError('文本为非字符串')
stats_text_cn(text,count)
stats_text_en(text,count)
stats_text(text,count)
33 changes: 33 additions & 0 deletions exercises/1901010132/day13/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
from wxpy import Bot,Message,embed

bot = Bot()
#找到好友
my_friend = bot.friends().search('PrincessAKing')[0]
#预先注册,利用Bot.register()完成
#Bot.register(chats=None,msg_types=None,except_self=True,run_async=True,enable=True)
@bot.register(chats = my_friend,msg_types = 'Sharing',except_self = True)
def auto_reply(msg):
import requests
from pyquery import PyQuery
#r = requests.get('https://api.github.com/user', auth=('user', 'pass')) 官方事例
response = requests.get(msg.url)
document = PyQuery(response.text)
content = document('#js_content').text()
from mymodule.stats_word import stats_text as a
msg1 = dict(a(content,20))

import numpy as np
import matplotlib.pyplot as plt
import matplotlib.font_manager as fm
import pandas as pd
from pandas import DataFrame,Series
plt.rcParams['font.sans-serif']=['SimHei']
group_x = list(msg1.keys())
group_y = list(msg1.values())
df = pd.DataFrame(group_y,index = group_x)
df.plot(kind = 'barh')

plt.savefig('day13.png')

msg.reply_image('day13.png')
embed()
50 changes: 50 additions & 0 deletions exercises/1901010132/day13/mymodule/stats_word.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
text= '''
"Her eyes beginning to water, she went on,
"So I would like you all to make me a promise:
from now on, on your way to school,
or on your way home, find something beautiful
to notice. It doesn' t have to be something you
see -it could be a scent perhaps of freshly
baked bread wafting out of someone 's house,
or it could be the sound of the breeze
slightly rustling the leaves in the trees,
or the way the morning light catches one
autumn leaf as it falls gently to the ground.
Please, look for these things, and remember them."
  她的眼睛开始湿润了,她接着说因此我想让你们每个人答应我:
从今以后,在你上学或者放学的路上,要发现一些美丽的事物。
它不一定是你看到的某个东西——它可能是一种香味——
也许是新鲜烤面包的味道从某一座房里飘出来,也许是微风轻拂树叶的声音,
或者是晨光照射在轻轻飘落的秋叶上的方式。请你们寻找这些东西并且记住它们吧。
'''
import re
import collections
import jieba #结巴中文分词
count=int()
def stats_text_en(text,count):
if type(text) == str:
b=re.sub(r'[^A-Za-z]',' ',text)
list1=b.split()
return(collections.Counter(list1).most_common(count))
else:
raise ValueError('文本为非字符串')

def stats_text_cn(text,count):
if not isinstance(text,str):
raise ValueError('文本为非字符串')
p=re.compile(u'[\u4e00-\u9fa5]')
a=re.findall(p,text)
str2=''.join(a)
seg_list = jieba.cut(str2,cut_all=False) #jieba.cut返回的结构是一个可迭代的生成器generator
newlist=[]
for i in seg_list:
if len(i) >= 2:
newlist.append(i)
return(collections.Counter(newlist).most_common(count))

def stats_text(text,count):
if not isinstance(text,str):
raise ValueError('文本为非字符串')
stats_text_cn(text,count)
stats_text_en(text,count)
stats_text(text,count)
8 changes: 8 additions & 0 deletions exercises/1901010132/day9/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from mymodule import stats_word
import json

with open(r'\Users\Administrator\Documents\GitHub\selfteaching-python-camp\exercises\1901010132\day9\tang300.json',encoding='UTF-8') as f:
text=f.read()


stats_word.stats_text_cn(text, 100)
42 changes: 42 additions & 0 deletions exercises/1901010132/day9/mymodule/stats_word.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
text= '''
"Her eyes beginning to water, she went on,
"So I would like you all to make me a promise:
from now on, on your way to school,
or on your way home, find something beautiful
to notice. It doesn' t have to be something you
see -it could be a scent perhaps of freshly
baked bread wafting out of someone 's house,
or it could be the sound of the breeze
slightly rustling the leaves in the trees,
or the way the morning light catches one
autumn leaf as it falls gently to the ground.
Please, look for these things, and remember them."
  她的眼睛开始湿润了,她接着说因此我想让你们每个人答应我:
从今以后,在你上学或者放学的路上,要发现一些美丽的事物。
它不一定是你看到的某个东西——它可能是一种香味——
也许是新鲜烤面包的味道从某一座房里飘出来,也许是微风轻拂树叶的声音,
或者是晨光照射在轻轻飘落的秋叶上的方式。请你们寻找这些东西并且记住它们吧。
'''
import re
import collections
count=int()
def stats_text_en(text,count):
if type(text)!=str:
raise ValueError("文本为非字符串")
text=re.sub('[^a-zA-Z]','',text.strip()) #表示所有非英文字母
text=text.split()
print(collections.Counter(text).most_common(count))

def stats_text_cn(text,count): #定义检索中文函数
if type(text)!=str:
raise ValueError("文本为非字符串")
text=re.sub('[^\u4e00-\u9fa5]','',text) #[^\u4e00-\u9fa5]表示所有非中文
text=' '.join(text)
text=text.split()
print(collections.Counter(text).most_common(count))

def stats_word(text,count): #定义函数,实现统计汉字和英文单词出现次数
if type(text)!=str:
raise ValueError("文本为非字符串")
stats_text_en(text,count)
stats_text_cn(text,count)