Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
568 commits
Select commit Hold shift + click to select a range
0af228d
add 0024 link
Jaccorot Oct 29, 2015
ac0f5ca
Problem 0010 solved
vvzwvv Nov 2, 2015
3ec1874
Problem 0004 solved
vvzwvv Nov 2, 2015
6c97b3d
Problem 0011 solved
vvzwvv Nov 3, 2015
40c5e11
Problem 0012 solved
vvzwvv Nov 3, 2015
f5a7456
complete 0000
messyidea Nov 4, 2015
1c4a85c
complete 0002
messyidea Nov 4, 2015
7243418
fix some bugs on problem 0000
messyidea Nov 5, 2015
8379ff2
complete problem 0002
Nov 5, 2015
89614c7
complete problem 0003
Nov 5, 2015
393481f
complete problem 0004
Nov 5, 2015
d9edf0e
complete problem 0005
Nov 5, 2015
3b3be19
第0013题
monkey-soft Nov 11, 2015
6f217b2
第0013题
monkey-soft Nov 16, 2015
551c5d1
完成第一题
Nov 16, 2015
3bd4462
Merge pull request #155 from monkey-soft/master
horx Nov 17, 2015
2cbb684
完成第1,2,4道题
Nov 17, 2015
b69d8c1
完成5,6,8,9
Nov 18, 2015
35f3ca0
删除无关的文件
Nov 23, 2015
3aecf2f
删除无关文件
Nov 23, 2015
7a0c23f
Merge pull request #156 from keysona/master
horx Nov 25, 2015
9baef80
11.30 solve 0001
Forec Nov 30, 2015
def94ff
add
Forec Dec 1, 2015
eb2101a
add
Forec Dec 1, 2015
1a77c56
Merge pull request #157 from Forec/master
horx Dec 2, 2015
2899ab9
add
Forec Dec 6, 2015
452cf2a
Merge pull request #160 from Forec/master
horx Dec 7, 2015
e27b2d8
add sarikasama
sarikasama Dec 16, 2015
2ef51b8
Merge pull request #161 from sarikasama/master
horx Dec 17, 2015
167b96f
Update
starlightme Dec 21, 2015
4c78c5c
Merge pull request #162 from starlightme/master
horx Dec 21, 2015
acf280a
Merge pull request #154 from messyidea/master
horx Dec 21, 2015
65410f0
Merge pull request #153 from vvzwvv/master
horx Dec 21, 2015
b33df8e
Merge pull request #152 from Jaccorot/master
horx Dec 21, 2015
8388a3d
Update 0013
monkey-soft Dec 30, 2015
c36d497
complete 0004
monkey-soft Dec 30, 2015
349a92a
Merge pull request #163 from monkey-soft/master
horx Dec 31, 2015
d912880
n
lwhile Jan 7, 2016
145b9a0
2016.01.06
yemaobumei Jan 7, 2016
4a6cbf6
readme
yemaobumei Jan 7, 2016
c99df75
Update active_code.py
lwhile Jan 7, 2016
8f14088
Merge remote-tracking branch 'upstream/master'
yemaobumei Jan 7, 2016
d902166
Merge pull request #165 from yemaobumei/master
horx Jan 7, 2016
8ca57cc
Merge pull request #164 from lwhhhh/master
horx Jan 7, 2016
fc03c37
add no.2
lwhile Jan 8, 2016
abd4aec
add no.4
lwhile Jan 9, 2016
ed8675d
Merge remote-tracking branch 'refs/remotes/Show-Me-the-Code/master'
lwhile Jan 9, 2016
63ee9c1
add 6
lwhile Jan 9, 2016
79cbc72
n
lwhile Jan 9, 2016
0456030
add
lwhile Jan 10, 2016
882ad23
Merge pull request #166 from lwhhhh/master
horx Jan 11, 2016
b2a161c
第七题
lwhile Jan 13, 2016
4cdbf4f
删除被统计的代码文件
lwhile Jan 13, 2016
28460b3
Merge pull request #167 from lwhhhh/master
horx Jan 14, 2016
64469e7
第十题
lwhile Jan 24, 2016
2a37cbe
add
lwhile Jan 24, 2016
d7844f5
Merge pull request #168 from lwhhhh/master
horx Jan 27, 2016
407fae2
12题,简单采用系统自带的find函数查找子串
Jan 27, 2016
cf04b08
14题
Jan 28, 2016
d44a72c
修改了在错误的sheet上工作的问题
Jan 28, 2016
e306163
新文件: crazyacking/0000/add_num.py
crazyacking Jan 28, 2016
1b8f13f
17题,完成得不是很完美(解决不了无法换行的问题)
Jan 29, 2016
4e05a60
可以统计时间
Jan 29, 2016
4294bd5
统计呼出和主叫信息
Jan 29, 2016
aa0530e
Create encrpyt.py
lwhile Jan 29, 2016
b06f19f
Merge pull request #170 from lwhhhh/master
horx Jan 30, 2016
f59a287
Merge pull request #169 from crazyacking/master
horx Jan 30, 2016
c179ce9
add
Feb 11, 2016
a3d1020
Merge branch 'master' of https://github.com/lwhhhh/python
Feb 11, 2016
02cbd75
Merge pull request #171 from lwhhhh/master
horx Feb 14, 2016
8cfaf78
将你的 QQ 头像(或者微博头像)右上角加上红色的数字
xieyajie Feb 16, 2016
1542a15
update test
xieyajie Feb 16, 2016
08acd3a
update
xieyajie Feb 16, 2016
c291c3f
add 0010
xieyajie Feb 16, 2016
cc184e3
添加函数描述
xieyajie Feb 16, 2016
f5ff3a2
生成随机码
xieyajie Feb 22, 2016
8f0f6d6
0004: 获取纯英文文件中单词个数
xieyajie Feb 22, 2016
d7aa7ce
0007: 计算代码行数
xieyajie Feb 23, 2016
f4af2b7
0005: 有一个目录,装了很多照片,把它们的尺寸变成都不大于 iPhone5 分辨率的大小
xieyajie Feb 26, 2016
d961e50
保存数据到redis
xieyajie Mar 7, 2016
30f97d5
readme: mac安装redis
xieyajie Mar 7, 2016
b3efd8e
first attempt
evan69 Mar 9, 2016
2b9ee28
finish 0000
evan69 Mar 10, 2016
c790535
finish 0001 and remove some files in 0000
evan69 Mar 10, 2016
a7e90a8
finish 0004 and 0007
evan69 Mar 10, 2016
e1e46df
add: 0006 统计出认为每篇日记最重要的词
xieyajie Mar 11, 2016
824adcb
add: 0011 查找敏感词
xieyajie Mar 11, 2016
15cfecf
add 0012: 替换敏感词
xieyajie Mar 11, 2016
3c58e97
Merge pull request #174 from evan69/master
horx Mar 13, 2016
34edbed
完成第一题
chris5641 Mar 15, 2016
f48c074
完成第二题
chris5641 Mar 15, 2016
4909bea
0002
chris5641 Mar 15, 2016
cbf0227
0003
chris5641 Mar 17, 2016
138c20a
将字典类型的文本写入xls
xieyajie Mar 18, 2016
3eead63
将list类型文本写到xls
xieyajie Mar 18, 2016
42345e8
first commit
rusia-rak Mar 20, 2016
456ba7d
0004
chris5641 Mar 20, 2016
31af5d5
Added files via upload
deng47 Mar 20, 2016
0728b99
Merge pull request #176 from deng47/master
horx Mar 21, 2016
c4b3bca
Merge pull request #175 from rusia-rak/master
horx Mar 21, 2016
1de49e6
将xls转为xml
xieyajie Mar 22, 2016
fb1ee09
First commit
sandeepbvv11 Mar 22, 2016
290cadb
First commit
sandeepbvv11 Mar 22, 2016
dc6988d
0005
chris5641 Mar 22, 2016
94df876
第0001题
deng47 Mar 23, 2016
07fa80d
Updated 0001.py
sandeepbvv11 Mar 23, 2016
1007618
Updated 0001.py
sandeepbvv11 Mar 23, 2016
564334a
0009:获取html中所有链接
xieyajie Mar 23, 2016
0e6071b
Added files via upload
deng47 Mar 24, 2016
0037e83
0008:获取html正文
xieyajie Mar 26, 2016
da5aeda
0013: 爬链接中的图片
xieyajie Mar 26, 2016
c936551
add AK-wang version
Mar 26, 2016
aa7e12b
update
xieyajie Mar 28, 2016
782e19d
0020:按月统计通话时间
xieyajie Mar 28, 2016
8e4df98
finish 0002
Mar 28, 2016
08aa514
clean code
Mar 28, 2016
49c7aa4
0021: 给密码加密
xieyajie Mar 29, 2016
c419ad0
finish 0003
Mar 29, 2016
6d3cc7f
add decorator version
Mar 30, 2016
2657765
pep8 style
Mar 30, 2016
98bc77d
0025: 语音打开浏览器搜索引擎
xieyajie Apr 15, 2016
8537dbc
Merge pull request #181 from Turkingwang/master
horx Apr 19, 2016
29a93eb
Merge pull request #180 from sandeepbvv11/master
horx Apr 19, 2016
07de37e
Merge pull request #179 from deng47/master
horx Apr 19, 2016
1b63fb2
Merge pull request #178 from chris5641/master
horx Apr 19, 2016
abfe6f6
Merge pull request #173 from Show-Me-the-Code/master
horx Apr 19, 2016
8c6be65
Merge pull request #172 from xieyajie/master
horx Apr 19, 2016
9ed29ce
added for 0011
robot527 Apr 22, 2016
d129274
Create Liez‘s Python Exercise
llapuras Apr 23, 2016
eeaf928
Delete Liez‘s Python Exercise
llapuras Apr 23, 2016
a813525
Added files via upload
llapuras Apr 23, 2016
a0cef69
Delete Liez-Python-Exercise-master.zip
llapuras Apr 23, 2016
009abfc
Create Liez
llapuras Apr 23, 2016
36e0e50
Added files via upload
llapuras Apr 23, 2016
d53c5b9
Create 0000.py
llapuras Apr 23, 2016
9fdb627
Added files via upload
llapuras Apr 23, 2016
c6102d1
Create 0001.py
llapuras Apr 23, 2016
5a69663
Added files via upload
llapuras Apr 23, 2016
73ed006
Delete 0001.py
llapuras Apr 23, 2016
c563bcb
Delete output_sample
llapuras Apr 23, 2016
e99ea87
Create 0001.py
llapuras Apr 23, 2016
6f44dac
Delete README.md
llapuras Apr 23, 2016
1596754
Added files via upload
llapuras Apr 23, 2016
911eaa5
Create 0002.py
llapuras Apr 23, 2016
d2cdf28
Create 0004.py
llapuras Apr 23, 2016
6e1144f
Added files via upload
llapuras Apr 23, 2016
89c4a25
Create 0005.py
llapuras Apr 23, 2016
2ee454c
Create 0010.py
llapuras Apr 23, 2016
bb82440
Added files via upload
llapuras Apr 23, 2016
8005408
Create 0011.py
llapuras Apr 23, 2016
845a416
Added files via upload
llapuras Apr 23, 2016
87622ad
Create 0012.py
llapuras Apr 23, 2016
340d901
Added files via upload
llapuras Apr 23, 2016
7ebded0
Create 0013.py
llapuras Apr 23, 2016
757db46
Create 0014.py
llapuras Apr 24, 2016
a04a259
Create student.txt
llapuras Apr 24, 2016
8483868
Create 0015.py
llapuras Apr 24, 2016
2f21a62
Create student.txt
llapuras Apr 24, 2016
a27e38d
Create 0017.py
llapuras Apr 24, 2016
662884b
Create 0020.py
llapuras Apr 24, 2016
ee0db8d
added for 0012
robot527 Apr 26, 2016
90b4373
Merge pull request #183 from chenwanwan13/master
horx May 3, 2016
ffe746b
Merge pull request #182 from robot527/master
horx May 3, 2016
0af4c0f
Merge pull request #184 from Turkingwang/master
horx May 3, 2016
6bad12a
避免循环调用list_txt
May 3, 2016
2412549
避免循环调用filtered_words函数
May 3, 2016
a721ebe
避免循环调用f_words[C
May 3, 2016
15cd012
寻找100000内素数,更快的方法
May 3, 2016
0333c18
my codes of Show-Me-Code
Tachone May 5, 2016
42c85fe
fix a bug
May 5, 2016
10c7f67
another method
May 5, 2016
4ea6996
0001
May 7, 2016
fc85e0c
0002
May 8, 2016
ab03cdb
daily task 0004
Poseiden May 17, 2016
4947cb7
process with space using strip
May 17, 2016
1276076
convert string to lower case
May 17, 2016
500f3c7
modified algorithm
May 17, 2016
e9c5879
Merge pull request #188 from tony-haibo-zhu/master
horx May 19, 2016
785e605
Merge pull request #186 from Turkingwang/master
horx May 19, 2016
55ba879
Merge pull request #185 from Tachone/master
horx May 19, 2016
4aefa2c
ooh my commit message
May 24, 2016
d7e911b
updated 8 and 9
May 24, 2016
84ec1cf
Merge pull request #189 from Dineshkarthik/master
horx May 25, 2016
f768269
finished pro1 and pro2
YixuanFranco Jun 2, 2016
c7e043b
Merge pull request #190 from YixuanFranco/master
horx Jun 2, 2016
0772c3e
走楼梯问题
Jun 2, 2016
74accf7
Merge pull request #191 from Turkingwang/master
horx Jun 2, 2016
d65d87b
make solution
howel52 Jun 3, 2016
4ed5930
add solution
howel52 Jun 3, 2016
7dc56e7
add a solution
howel52 Jun 3, 2016
342dc4c
Merge pull request #192 from lenzzz/master
horx Jun 6, 2016
1768a69
add 0000 file
Drake-Z Jun 16, 2016
f9050ec
add 0000 file
Drake-Z Jun 16, 2016
f81fea7
Add 0001 file
Drake-Z Jun 16, 2016
560d1bb
Fix
Drake-Z Jun 16, 2016
39257b5
Add 0001 file
Drake-Z Jun 16, 2016
1ba9512
Fix 0000
Drake-Z Jun 16, 2016
f9f2f18
Add 0002 file
Drake-Z Jun 16, 2016
19d20f6
Add 0002 file
Drake-Z Jun 16, 2016
ff7f69c
Fix 0003
Drake-Z Jun 16, 2016
1686400
Add 0003 file
Drake-Z Jun 16, 2016
5a286ef
Fix
Drake-Z Jun 16, 2016
198daec
Fix
Drake-Z Jun 16, 2016
85d1251
Fix 0002
Drake-Z Jun 16, 2016
793b273
Add 0004 file
Drake-Z Jun 16, 2016
47d4623
Add 0004 file
Drake-Z Jun 16, 2016
a853f2f
Add 0005 file
Drake-Z Jun 16, 2016
947398f
Fix 0001
Drake-Z Jun 16, 2016
ae38c19
Fix 0003
Drake-Z Jun 16, 2016
abe9719
Fix 0003 and 0004
Drake-Z Jun 16, 2016
bb08cd3
Fix 0004
Drake-Z Jun 16, 2016
5be83a8
Fix note
Drake-Z Jun 16, 2016
be7a105
Fix note
Drake-Z Jun 16, 2016
0dc5301
Fix 0006
Drake-Z Jun 17, 2016
25a04ac
Add 0006 file
Drake-Z Jun 17, 2016
11824ff
Add 0005 file
Drake-Z Jun 17, 2016
0043b02
Add 0007 file
Drake-Z Jun 17, 2016
4d5fc2b
Fix 0007
Drake-Z Jun 17, 2016
d9e87cd
Add 0008 file
Drake-Z Jun 17, 2016
1c064f2
Add 0009 file
Drake-Z Jun 17, 2016
971c9c4
Fix note
Drake-Z Jun 17, 2016
189e3f2
Add 0010 file
Drake-Z Jun 17, 2016
2078e16
Add 0011 file
Drake-Z Jun 17, 2016
ec4e4b9
Add 0011 file
Drake-Z Jun 17, 2016
87bef18
Add 0012 file
Drake-Z Jun 17, 2016
5656330
Add 0013 file
Drake-Z Jun 17, 2016
a459618
Add 0014 file
Drake-Z Jun 17, 2016
f41a9dd
Add 0015 file
Drake-Z Jun 17, 2016
114e65f
Fix 0014-0016
Drake-Z Jun 17, 2016
5f6899d
Fix 0015 0016
Drake-Z Jun 17, 2016
7f69ba0
Fix 0016
Drake-Z Jun 17, 2016
7586c8d
Add 0017-0019
Drake-Z Jun 17, 2016
18cb696
Add 0020-0022
Drake-Z Jun 17, 2016
69dfa89
Fix 0006
Drake-Z Jun 17, 2016
4564269
Add note
Drake-Z Jun 17, 2016
7ec7737
Fix 0013
Drake-Z Jun 17, 2016
df9c418
Fix 0009
Drake-Z Jun 17, 2016
9a92fb7
Fix 0014
Drake-Z Jun 18, 2016
8736adb
Fix 0014
Drake-Z Jun 18, 2016
fd752db
Fix 0014
Drake-Z Jun 18, 2016
ea7642d
Fix 0015
Drake-Z Jun 18, 2016
a3ee5a2
Fix 0016
Drake-Z Jun 18, 2016
5ebb574
Fix 0014 0015 0016
Drake-Z Jun 18, 2016
a334b1b
Fix 0014,0015,0016
Drake-Z Jun 18, 2016
51d85cf
Fix 0017
Drake-Z Jun 18, 2016
c11c4ad
Fix 0014
Drake-Z Jun 18, 2016
177302a
Fix 0018 0019
Drake-Z Jun 18, 2016
cd9c10a
Delete file
Drake-Z Jun 18, 2016
cc18968
Merge pull request #199 from Show-Me-the-Code/revert-61-master
horx Jun 24, 2016
f19071c
Merge pull request #198 from Drake-Z/master
horx Jun 24, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,4 @@ target/

# Mac File
.DS_Store
.idea
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "JiYouMCC"]
path = JiYouMCC
url = https://github.com/JiYouMCC/python-show-me-the-code
14 changes: 14 additions & 0 deletions 4disland/0000/add_num.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from PIL import Image, ImageDraw, ImageFont

def add_num(img):
draw = ImageDraw.Draw(img)
myfont = ImageFont.truetype('C:/windows/fonts/Arial.ttf', size=40)
fillcolor = "#ff0000"
width, height = img.size
draw.text((width-40, 0), '99', font=myfont, fill=fillcolor)
img.save('result.jpg','jpeg')

return 0
if __name__ == '__main__':
image = Image.open('image.jpg')
add_num(image)
37 changes: 37 additions & 0 deletions AK-wang/0001/key_gen.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/usr/bin/env python
# -*-coding:utf-8-*-

# 第 0001 题:做为 Apple Store App 独立开发者,你要搞限时促销,为你的应用生成激活码(或者优惠券),
# 使用 Python 如何生成 200 个激活码(或者优惠券)?

import string
import random

KEY_LEN = 20
KEY_ALL = 200


def base_str():
return (string.letters + string.digits)


def key_gen():
keylist = [random.choice(base_str()) for i in range(KEY_LEN)]
return ("".join(keylist))


def key_num(num, result=None):
if result is None:
result = []
for i in range(num):
result.append(key_gen())
return result


def print_key(num):
for i in key_num(num):
print i


if __name__ == "__main__":
print_key(KEY_ALL)
41 changes: 41 additions & 0 deletions AK-wang/0001/key_gen_deco.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/env python
# -*-coding:utf-8-*-

# 第 0001 题:做为 Apple Store App 独立开发者,你要搞限时促销,为你的应用生成激活码(或者优惠券),
# 使用 Python 如何生成 200 个激活码(或者优惠券)?

import string
import random

KEY_LEN = 20
KEY_ALL = 200


def base_str():
return (string.letters+string.digits)


def key_gen():
keylist = [random.choice(base_str()) for i in range(KEY_LEN)]
return ("".join(keylist))


def print_key(func):
def _print_key(num):
for i in func(num):
print i
return _print_key


@print_key
def key_num(num, result=None):
if result is None:
result = []
for i in range(num):
result.append(key_gen())
return result


if __name__ == "__main__":
# print_key(KEY_ALL)
key_num(KEY_ALL)
131 changes: 131 additions & 0 deletions AK-wang/0002/save_key.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
#!/usr/bin/env python
# -*-coding:utf-8-*-

# 第 0002 题:将 0001 题生成的 200 个激活码(或者优惠券)保存到 MySQL 关系型数据库中。

import MySQLdb
import string
import random

KEY_LEN = 20
KEY_ALL = 200


def base_str():
return (string.letters + string.digits)


def key_gen():
keylist = [random.choice(base_str()) for i in range(KEY_LEN)]
return ("".join(keylist))


def key_num(num, result=None):
if result is None:
result = []
for i in range(num):
result.append(str(key_gen()))
return result


class mysql_init(object):

def __init__(self, conn):
self.conn = None

# connect to mysql
def connect(self):
self.conn = MySQLdb.connect(
host="localhost",
port=3306,
user="root",
passwd="123456",
db="test",
charset="utf8"
)

def cursor(self):
try:
return self.conn.cursor()
except (AttributeError, MySQLdb.OperationalError):
self.connect()
return self.conn.cursor()

def commit(self):
return self.conn.commit()

def close(self):
return self.conn.close()


def process():
dbconn.connect()
conn = dbconn.cursor()
DropTable(conn)
CreateTable(conn)
InsertDatas(conn)
QueryData(conn)
dbconn.close()

# def execute(sql):
# '''执行sql'''
# conn=dbconn.cursor()
# conn.execute(sql)

# def executemany(sql, tmp):
# '''插入多条数据'''
# conn=dbconn.cursor()
# conn.executemany(sql,tmp)


def query(sql, conn):
'''查询sql'''
# conn=dbconn.cursor()
conn.execute(sql)
rows = conn.fetchall()
return rows


def DropTable(conn):
# conn=dbconn.cursor()
conn.execute("DROP TABLE IF EXISTS `user_key`")


def CreateTable(conn):
# conn=dbconn.cursor()
sql_create = ''' CREATE TABLE `user_key` (`key` varchar(50) NOT NULL)'''
conn.execute(sql_create)


def InsertDatas(conn):
# conn=dbconn.cursor()
# insert_sql = "insert into user_key values(%s)"
insert_sql = "INSERT INTO user_key VALUES (%(value)s)"
key_list = key_num(KEY_ALL)
# print len(key_list)
# conn.executemany(insert_sql,str(key_listi))
# conn.executemany("INSERT INTO user_key VALUES (%(value)s)",
# [dict(value=v) for v in key_list])
conn.executemany(insert_sql, [dict(value=v) for v in key_list])


def DeleteData():
del_sql = "delete from user_key where id=2"
execute(del_sql)


def QueryData(conn):
sql = "select * from user_key"
rows = query(sql, conn)
printResult(rows)


def printResult(rows):
if rows is None:
print "rows None"
for row in rows:
print row

if __name__ == "__main__":
dbconn = mysql_init(None)
process()
48 changes: 48 additions & 0 deletions AK-wang/0003/save_to_redis.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/usr/bin/env python
# -*-coding:utf-8-*-

# 第 0003 题:将 0001 题生成的 200 个激活码(或者优惠券)保存到 Redis 非关系型数据库中。

import string
import random
import redis

KEY_LEN = 20
KEY_ALL = 200


def base_str():
return (string.letters + string.digits)


def key_gen():
keylist = [random.choice(base_str()) for i in range(KEY_LEN)]
return ("".join(keylist))


def key_num(num, result=None):
if result is None:
result = []
for i in range(num):
result.append(key_gen())
return result


def redis_init():
r = redis.Redis(host='localhost', port=6379, db=0)
return r


def push_to_redis(key_list):
for key in key_list:
redis_init().lpush('key', key)


def get_from_redis():
key_list = redis_init().lrange('key', 0, -1)
for key in key_list:
print key

if __name__ == "__main__":
push_to_redis(key_num(200))
get_from_redis()
24 changes: 24 additions & 0 deletions AK-wang/0004/0004.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env python
# -*-coding:utf-8-*-

# 第 0004 题:任一个英文的纯文本文件,统计其中的单词出现的个数

from collections import Counter
import re


def creat_list(filename):
datalist = []
with open(filename, 'r') as f:
for line in f:
content = re.sub("\"|,|\.", "", line)
datalist.extend(content.strip().split(' '))
return datalist


def wc(filename):
print Counter(creat_list(filename))

if __name__ == "__main__":
filename = 'test.txt'
wc(filename)
4 changes: 4 additions & 0 deletions AK-wang/0004/test.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
In the latest move to support the economy,
Shanghai, Beijing, Chongqing and six other provinces and municipalities will allow banks to refinance high-quality credit assets rated by the People's Bank of China,
said the central bank, as the program was first introduced in Guangdong and Shandong provinces last year.

5 changes: 5 additions & 0 deletions AK-wang/0006/00.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
In China, when people go across the road, they will never wait for the red light
patiently. In fact, Chinese people are famous for running the green light, it
seems to be a habit for them, the traffic rule is just the paper for them, they
never obey it. The result of going against the traffic rule is serious.
we we we we we we we
8 changes: 8 additions & 0 deletions AK-wang/0006/01.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
On the one hand, running the red light is not a civilized behavior, Chinese
people will bring the foreign people the bad impression. When a foreigner comes
to China, he is so curious about the way Chinese people go across the road, he
waits for the green light, while a lot of Chinese people ignore the traffic
rule and go directly. He feels so hilarious about the situation, it is so
uncivilized behavior.
python python python python python python python python python python python
is the best useful language!
4 changes: 4 additions & 0 deletions AK-wang/0006/02.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
On the other hand, running the red light results in accident, people will lose
their lives. Every year, many people die of car accident, the main reason is
that they do not obey the traffic rule, when they go across the road, the car
hits them and the tragedy happens.
32 changes: 32 additions & 0 deletions AK-wang/0006/key_word.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env python
# -*-coding:utf-8-*-

# 第 0006 题:你有一个目录,放了你一个月的日记,都是 txt,为了避免分词的问题,假设内容都是英文,请统计出你认为每篇日记最重要的词。

import glob
from collections import Counter
import re


def list_txt():
return glob.glob("*.txt")


def wc(filename):
datalist = []
with open(filename, 'r') as f:
for line in f:
content = re.sub("\"|,|\.", "", line)
datalist.extend(content.strip().split(' '))
# print datalist
return Counter(datalist).most_common(1)


def most_comm():
all_txt = list_txt()
for txt in all_txt:
print wc(txt)

if __name__ == "__main__":
# most_comm()
print map(wc, list_txt())
30 changes: 30 additions & 0 deletions AK-wang/0011/filtered_words.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env python
# -*-coding:utf-8-*-

# 第 0011 题: 敏感词文本文件 filtered_words.txt,里面的内容为以下内容,
# 当用户输入敏感词语时,则打印出 Freedom,否则打印出 Human Rights。


def filtered_words(f_file):
filtered_list = []
with open(f_file, 'r') as f:
for line in f:
filtered_list.append(line.strip())
return filtered_list


def filtered_or_not(input_word, f_file):
filtered_words_list = filtered_words(f_file)
return (input_word in filtered_words_list)


def print_user_input(input_word, f_file):
if filtered_or_not(input_word, f_file):
return "Freedom"
return "Human Rights"


if __name__ == "__main__":
input_word = raw_input("please input your word:")
f_file = "filtered_words.txt"
print print_user_input(input_word, f_file)
Loading