Skip to content

Commit c936551

Browse files
author
wangxiaoxian
committed
add AK-wang version
1 parent c4b3bca commit c936551

File tree

9 files changed

+318
-0
lines changed

9 files changed

+318
-0
lines changed

AK-wang/0001/key_gen.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/usr/bin/env python
2+
3+
import string
4+
import random
5+
6+
KEY_LEN = 20
7+
KEY_ALL = 200
8+
9+
def base_str():
10+
return (string.letters+string.digits)
11+
12+
def key_gen():
13+
keylist = [random.choice(base_str()) for i in range(KEY_LEN)]
14+
return ("".join(keylist))
15+
16+
def key_num(num,result=None):
17+
if result is None:
18+
result = []
19+
for i in range(num):
20+
result.append(key_gen())
21+
return result
22+
23+
def print_key(num):
24+
for i in key_num(num):
25+
print i
26+
27+
if __name__ == "__main__":
28+
print_key(KEY_ALL)
29+

AK-wang/0004/0004.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/env python
2+
3+
import collections
4+
import re
5+
6+
def wc(filename):
7+
datalist = []
8+
with open(filename,'r') as f:
9+
for line in f:
10+
content = re.sub("\"|,|\.","",line)
11+
datalist.extend(content.strip().split(' '))
12+
#print datalist
13+
print collections.Counter(datalist)
14+
15+
if __name__ == "__main__":
16+
filename = 'test.txt'
17+
wc(filename)

AK-wang/0006/00.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
In China, when people go across the road, they will never wait for the red light
2+
patiently. In fact, Chinese people are famous for running the green light, it
3+
seems to be a habit for them, the traffic rule is just the paper for them, they
4+
never obey it. The result of going against the traffic rule is serious.
5+
we we we we we we we

AK-wang/0006/01.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
On the one hand, running the red light is not a civilized behavior, Chinese
2+
people will bring the foreign people the bad impression. When a foreigner comes
3+
to China, he is so curious about the way Chinese people go across the road, he
4+
waits for the green light, while a lot of Chinese people ignore the traffic
5+
rule and go directly. He feels so hilarious about the situation, it is so
6+
uncivilized behavior.
7+
python python python python python python python python python python python
8+
is the best useful language!

AK-wang/0006/02.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
On the other hand, running the red light results in accident, people will lose
2+
their lives. Every year, many people die of car accident, the main reason is
3+
that they do not obey the traffic rule, when they go across the road, the car
4+
hits them and the tragedy happens.

AK-wang/0006/key_word.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/usr/bin/env python
2+
3+
import glob
4+
from collections import Counter
5+
import re
6+
7+
def list_txt():
8+
return glob.glob("*.txt")
9+
10+
def wc(filename):
11+
datalist = []
12+
with open(filename,'r') as f:
13+
for line in f:
14+
content = re.sub("\"|,|\.","",line)
15+
datalist.extend(content.strip().split(' '))
16+
#print datalist
17+
return Counter(datalist).most_common(1)
18+
19+
def most_comm():
20+
for txt in list_txt():
21+
print wc(txt)
22+
23+
if __name__ == "__main__":
24+
most_comm()

AK-wang/0011/filtered_words.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/usr/bin/env python
2+
3+
def filtered_words(f_file):
4+
filtered_list = []
5+
with open(f_file,'r') as f:
6+
for line in f:
7+
filtered_list.append(line.strip())
8+
return filtered_list
9+
10+
def filtered_or_not(input_word,f_file):
11+
return (input_word in filtered_words(f_file))
12+
13+
def print_user_input(input_word,f_file):
14+
if filtered_or_not(input_word,f_file):
15+
return "Freedom"
16+
return "Human Rights"
17+
18+
if __name__ == "__main__":
19+
input_word = raw_input("please input your word:")
20+
f_file = "filtered_words.txt"
21+
print print_user_input(input_word,f_file)

AK-wang/0011/filtered_words.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
北京
2+
程序员
3+
公务员
4+
领导
5+
牛比
6+
牛逼
7+
你娘
8+
你妈
9+
love
10+
sex
11+
jiangge

AK-wang/README.md

Lines changed: 199 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,199 @@
1+
## Python 练习册,每天一个小程序 ##
2+
3+
4+
#### 说明: ####
5+
6+
- Python 练习册,每天一个小程序。注:将 Python 换成其他语言,大多数题目也适用
7+
- 不会出现诸如「打印九九乘法表」、「打印水仙花」之类的题目
8+
- [点此链接,会看到每个题目的代码, 欢迎大家 Pull Request 出题目,贴代码(Gist、Blog皆可),Pull Request 请提交你个人的仓库 URL 链接地址。现在项目太大了,提交 URL 吧 :+1: :-)](https://github.com/Show-Me-the-Code/python)
9+
- 本文本文由@史江歌(shijiangge@gmail.com QQ:499065469)根据互联网资料收集整理而成,感谢互联网,感谢各位的分享。鸣谢!本文会不断更新。
10+
11+
> Talk is cheap. Show me the code.--Linus Torvalds
12+
13+
----------
14+
15+
**第 0000 题:**将你的 QQ 头像(或者微博头像)右上角加上红色的数字,类似于微信未读信息数量那种提示效果。
16+
类似于图中效果
17+
18+
![头像](http://i.imgur.com/sg2dkuY.png?1)
19+
20+
**第 0001 题:**做为 Apple Store App 独立开发者,你要搞限时促销,为你的应用**生成激活码**(或者优惠券),使用 Python 如何生成 200 个激活码(或者优惠券)?
21+
22+
**第 0002 题**:将 0001 题生成的 200 个激活码(或者优惠券)保存到 **MySQL** 关系型数据库中。
23+
24+
**第 0003 题:**将 0001 题生成的 200 个激活码(或者优惠券)保存到 **Redis** 非关系型数据库中。
25+
26+
**第 0004 题:**任一个英文的纯文本文件,统计其中的单词出现的个数。
27+
28+
**第 0005 题:**你有一个目录,装了很多照片,把它们的尺寸变成都不大于 iPhone5 分辨率的大小。
29+
30+
**第 0006 题:**你有一个目录,放了你一个月的日记,都是 txt,为了避免分词的问题,假设内容都是英文,请统计出你认为每篇日记最重要的词。
31+
32+
**第 0007 题:**有个目录,里面是你自己写过的程序,统计一下你写过多少行代码。包括空行和注释,但是要分别列出来。
33+
34+
**第 0008 题:**一个HTML文件,找出里面的**正文**
35+
36+
**第 0009 题:**一个HTML文件,找出里面的**链接**
37+
38+
**第 0010 题:**使用 Python 生成类似于下图中的**字母验证码图片**
39+
40+
![字母验证码](http://i.imgur.com/aVhbegV.jpg)
41+
42+
- [阅读资料](http://stackoverflow.com/questions/2823316/generate-a-random-letter-in-python)
43+
44+
**第 0011 题:** 敏感词文本文件 filtered_words.txt,里面的内容为以下内容,当用户输入敏感词语时,则打印出 Freedom,否则打印出 Human Rights。
45+
46+
北京
47+
程序员
48+
公务员
49+
领导
50+
牛比
51+
牛逼
52+
你娘
53+
你妈
54+
love
55+
sex
56+
jiangge
57+
58+
**第 0012 题:** 敏感词文本文件 filtered_words.txt,里面的内容 和 0011题一样,当用户输入敏感词语,则用 星号 * 替换,例如当用户输入「北京是个好城市」,则变成「**是个好城市」。
59+
60+
**第 0013 题:** 用 Python 写一个爬图片的程序,爬 [这个链接里的日本妹子图片 :-)](http://tieba.baidu.com/p/2166231880)
61+
62+
- [参考代码](http://www.v2ex.com/t/61686 "参考代码")
63+
64+
**第 0014 题:** 纯文本文件 student.txt为学生信息, 里面的内容(包括花括号)如下所示:
65+
66+
{
67+
"1":["张三",150,120,100],
68+
"2":["李四",90,99,95],
69+
"3":["王五",60,66,68]
70+
}
71+
72+
请将上述内容写到 student.xls 文件中,如下图所示:
73+
74+
![student.xls](http://i.imgur.com/nPDlpme.jpg)
75+
76+
- [阅读资料](http://www.cnblogs.com/skynet/archive/2013/05/06/3063245.html) 腾讯游戏开发 XML 和 Excel 内容相互转换
77+
78+
**第 0015 题:** 纯文本文件 city.txt为城市信息, 里面的内容(包括花括号)如下所示:
79+
80+
{
81+
"1" : "上海",
82+
"2" : "北京",
83+
"3" : "成都"
84+
}
85+
86+
请将上述内容写到 city.xls 文件中,如下图所示:
87+
88+
![city.xls](http://i.imgur.com/rOHbUzg.png)
89+
90+
91+
**第 0016 题:** 纯文本文件 numbers.txt, 里面的内容(包括方括号)如下所示:
92+
93+
[
94+
[1, 82, 65535],
95+
[20, 90, 13],
96+
[26, 809, 1024]
97+
]
98+
99+
请将上述内容写到 numbers.xls 文件中,如下图所示:
100+
101+
![numbers.xls](http://i.imgur.com/iuz0Pbv.png)
102+
103+
**第 0017 题:** 将 第 0014 题中的 student.xls 文件中的内容写到 student.xml 文件中,如
104+
105+
下所示:
106+
107+
<?xml version="1.0" encoding="UTF-8"?>
108+
<root>
109+
<students>
110+
<!--
111+
学生信息表
112+
"id" : [名字, 数学, 语文, 英文]
113+
-->
114+
{
115+
"1" : ["张三", 150, 120, 100],
116+
"2" : ["李四", 90, 99, 95],
117+
"3" : ["王五", 60, 66, 68]
118+
}
119+
</students>
120+
</root>
121+
122+
123+
**第 0018 题:** 将 第 0015 题中的 city.xls 文件中的内容写到 city.xml 文件中,如下所示:
124+
125+
<?xmlversion="1.0" encoding="UTF-8"?>
126+
<root>
127+
<citys>
128+
<!--
129+
城市信息
130+
-->
131+
{
132+
"1" : "上海",
133+
"2" : "北京",
134+
"3" : "成都"
135+
}
136+
</citys>
137+
</root>
138+
139+
**第 0019 题:** 将 第 0016 题中的 numbers.xls 文件中的内容写到 numbers.xml 文件中,如下
140+
141+
所示:
142+
143+
<?xml version="1.0" encoding="UTF-8"?>
144+
<root>
145+
<numbers>
146+
<!--
147+
数字信息
148+
-->
149+
150+
[
151+
[1, 82, 65535],
152+
[20, 90, 13],
153+
[26, 809, 1024]
154+
]
155+
156+
</numbers>
157+
</root>
158+
159+
**第 0020 题:** [登陆中国联通网上营业厅](http://iservice.10010.com/index_.html) 后选择「自助服务」 --> 「详单查询」,然后选择你要查询的时间段,点击「查询」按钮,查询结果页面的最下方,点击「导出」,就会生成类似于 2014年10月01日~2014年10月31日通话详单.xls 文件。写代码,对每月通话时间做个统计。
160+
161+
**第 0021 题:** 通常,登陆某个网站或者 APP,需要使用用户名和密码。密码是如何加密后存储起来的呢?请使用 Python 对密码加密。
162+
163+
- 阅读资料 [用户密码的存储与 Python 示例](http://zhuoqiang.me/password-storage-and-python-example.html)
164+
165+
- 阅读资料 [Hashing Strings with Python](http://www.pythoncentral.io/hashing-strings-with-python/)
166+
167+
- 阅读资料 [Python's safest method to store and retrieve passwords from a database](http://stackoverflow.com/questions/2572099/pythons-safest-method-to-store-and-retrieve-passwords-from-a-database)
168+
169+
**第 0022 题:** iPhone 6、iPhone 6 Plus 早已上市开卖。请查看你写得 第 0005 题的代码是否可以复用。
170+
171+
**第 0023 题:** 使用 Python 的 Web 框架,做一个 Web 版本 留言簿 应用。
172+
173+
[阅读资料:Python 有哪些 Web 框架](http://v2ex.com/t/151643#reply53)
174+
175+
- ![留言簿参考](http://i.imgur.com/VIyCZ0i.jpg)
176+
177+
178+
**第 0024 题:** 使用 Python 的 Web 框架,做一个 Web 版本 TodoList 应用。
179+
180+
- ![SpringSide 版TodoList](http://i.imgur.com/NEf7zHp.jpg)
181+
182+
**第 0025 题:** 使用 Python 实现:对着电脑吼一声,自动打开浏览器中的默认网站。
183+
184+
185+
例如,对着笔记本电脑吼一声“百度”,浏览器自动打开百度首页。
186+
187+
关键字:Speech to Text
188+
189+
参考思路:
190+
1:获取电脑录音-->WAV文件
191+
python record wav
192+
193+
2:录音文件-->文本
194+
195+
STT: Speech to Text
196+
197+
STT API Google API
198+
199+
3:文本-->电脑命令

0 commit comments

Comments
 (0)