Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
417 commits
Select commit Hold shift + click to select a range
e21e931
del .idea
llluiop May 20, 2015
892cb52
Merge pull request #115 from llluiop/master
horx May 20, 2015
b29f9b4
add 0007
llluiop May 20, 2015
27d8bf8
Merge pull request #116 from llluiop/master
horx May 21, 2015
5fb0ea1
add 0008
llluiop May 23, 2015
0568cee
Merge pull request #117 from llluiop/master
horx May 24, 2015
3e62801
add 0009
llluiop May 25, 2015
c0f5d76
Merge pull request #118 from llluiop/master
horx May 25, 2015
90a56d9
add 0010
llluiop May 25, 2015
338a70c
add 0011
llluiop May 25, 2015
2e5c08d
add 0012
llluiop May 25, 2015
2ef986e
Merge pull request #119 from llluiop/master
horx May 25, 2015
2cf1bc6
add 0013
llluiop Jun 1, 2015
3b38204
del
llluiop Jun 1, 2015
b3dfb1c
add 0014
llluiop Jun 2, 2015
084fb56
make it compliable
llluiop Jun 4, 2015
b5392f5
Merge pull request #120 from llluiop/master
horx Jun 4, 2015
0ec2876
first commit
Silocean Jun 5, 2015
965e389
second commit
Silocean Jun 5, 2015
06b0ba4
second commit
Silocean Jun 5, 2015
f5b887e
third commit
Silocean Jun 5, 2015
e9e9c04
the third commitment
Silocean Jun 6, 2015
6fe0cd3
12 changes
Silocean Jun 6, 2015
b4c6a15
add
llluiop Jun 6, 2015
94ae9b8
Merge pull request #121 from Silocean/master
horx Jun 6, 2015
7930c42
Merge pull request #122 from llluiop/master
horx Jun 6, 2015
f60d585
add 0020
llluiop Jun 9, 2015
734842f
Merge pull request #123 from llluiop/master
horx Jun 9, 2015
aad5b02
finish 0017,0018,0019
Silocean Jun 9, 2015
23e4551
Merge pull request #124 from Silocean/master
horx Jun 10, 2015
e1726b4
finish 0006
Silocean Jun 10, 2015
68e0042
finish 0005
Silocean Jun 10, 2015
365b24d
finish 0001
Silocean Jun 10, 2015
7eebbfe
finish 0002
Silocean Jun 10, 2015
38b9af4
add 0021
llluiop Jun 10, 2015
8243a9b
finish 0003
Silocean Jun 10, 2015
99c524b
Merge pull request #125 from llluiop/master
horx Jun 10, 2015
b8f9a39
Merge pull request #126 from Silocean/master
horx Jun 10, 2015
e653aec
add django
llluiop Jun 11, 2015
beac035
0001
cijianzy Jun 14, 2015
7b400b5
0001
cijianzy Jun 14, 2015
30bf1f5
Merge pull request #127 from cijianzy/master
horx Jun 14, 2015
bcb734c
finish 0023
llluiop Jun 24, 2015
bc0f803
del
llluiop Jun 24, 2015
6afdaeb
Merge pull request #129 from llluiop/master
horx Jun 24, 2015
22c64ac
generate coupons
PyBeaner Jun 30, 2015
1d2ff87
save to mysql
PyBeaner Jun 30, 2015
b2124df
word counter
PyBeaner Jun 30, 2015
1a8644c
count lines
Jun 30, 2015
309a00e
get html text
Jun 30, 2015
df7b416
get links of html
Jun 30, 2015
b1429c4
word filter
Jun 30, 2015
52b5da0
word filter
Jun 30, 2015
2e026b4
Merge pull request #131 from PyBeaner/master
horx Jul 1, 2015
1b04262
complete 0000~0001
luoxufeiyan Jul 9, 2015
3bd7f7a
Merge pull request #132 from luoxufeiyan/lxfy
horx Jul 9, 2015
f7185a5
PE1
Jul 27, 2015
fa09d0a
Merge pull request #133 from karnikamit/master
horx Jul 28, 2015
a55da6c
Pull Request 请提交你个人的仓库 URL 链接地址
Yixiaohan Aug 10, 2015
5bd6d46
sophie2805/0001
sophie2805 Aug 12, 2015
4d2dc7d
Create friday
Friday21 Aug 24, 2015
c3991d4
Delete friday
Friday21 Aug 24, 2015
b7552cf
add 0000
Friday21 Aug 25, 2015
27ea899
remove firday
Friday21 Aug 25, 2015
fc8bcb2
add 0000,0001
Friday21 Aug 25, 2015
53a8c52
add 0000.py
Friday21 Aug 25, 2015
d5fa833
finish 0001
Friday21 Aug 25, 2015
b4f8c30
Merge pull request #138 from Friday21/master
horx Aug 26, 2015
f53fea4
Merge pull request #137 from sophie2805/master
horx Aug 26, 2015
a1cf409
Create zeyue
Zeyue Aug 31, 2015
f74fbbc
Delete zeyue
Zeyue Aug 31, 2015
2a6ce8d
Get files list in directory and check if one line is an inline commen…
Zeyue Aug 31, 2015
c835b1a
finish #0011
Sep 1, 2015
0026ee4
finish #0012
Sep 1, 2015
bd20070
Merge pull request #139 from hooting/master
horx Sep 1, 2015
5d2468b
First version(cannot recognize multiple line comments)
Sep 1, 2015
620c524
multiple comment detected
Zeyue Sep 1, 2015
55b41a3
clean temp files
Zeyue Sep 1, 2015
b439fc0
support to check c files
Sep 2, 2015
dde19a1
remove files not necassary
Sep 2, 2015
c04fd61
using console argument as input
Sep 2, 2015
c4ef640
Merge pull request #140 from Zeyue/master
horx Sep 4, 2015
d5e630e
add 0000 answes
Sep 6, 2015
a0ff91a
add 0000 answes
Sep 6, 2015
74a01d9
Merge branch 'master' into asahiSky
Sep 6, 2015
35e2ac8
add 0001 answers
Sep 6, 2015
b7a0651
add 0011 answers
Sep 6, 2015
6be60ec
Merge pull request #5 from Show-Me-the-Code/master
JiYouMCC Sep 7, 2015
2ba51d1
using submodule
Sep 7, 2015
9c74663
Using submodule
Sep 7, 2015
579b24a
add submodule
Sep 7, 2015
601d7c6
Merge pull request #143 from JiYouMCC/master
horx Sep 7, 2015
1b1dd03
Create README.md
Zeyue Sep 7, 2015
a6e5f00
Merge pull request #144 from Zeyue/patch-1
horx Sep 9, 2015
76e2811
add 0011
Sep 11, 2015
6a22de9
add 0021
Sep 13, 2015
b2cac1f
none
Kxrr Sep 15, 2015
a37ad26
0004 solved
Kxrr Sep 15, 2015
0382edb
0004 solved
Kxrr Sep 15, 2015
43098aa
add readme
Kxrr Sep 15, 2015
a356626
none
Kxrr Sep 15, 2015
a17b083
0004 solved
Kxrr Sep 15, 2015
1a0a173
'0003 solved'
Kxrr Sep 15, 2015
33fe750
0000 solved
Kxrr Sep 15, 2015
b998901
Merge pull request #145 from Kxrr/master
horx Sep 16, 2015
3041de3
python test 0000
Oct 8, 2015
5980eea
python test 0000
Oct 8, 2015
20205a2
test 0001
Oct 9, 2015
a59431d
add 0001
Jaccorot Oct 11, 2015
1e8ad20
add 0001
Jaccorot Oct 12, 2015
815d758
add 0002
Jaccorot Oct 12, 2015
1ed31e4
add 0003
Jaccorot Oct 12, 2015
bc75424
Merge branch 'master' of github.com:Jaccorot/python
Jaccorot Oct 12, 2015
b46e227
python test 0004
Oct 12, 2015
e045b74
add 0000
Jaccorot Oct 13, 2015
f0021a4
Merge pull request #147 from Jaccorot/master
horx Oct 13, 2015
d48fbd2
Merge pull request #146 from ShaoyuanLi/master
horx Oct 13, 2015
deab557
Merge pull request #141 from asahiSky/asahiSky
horx Oct 13, 2015
fc9b8a6
add 0004
Jaccorot Oct 13, 2015
68b3823
add 0005
Jaccorot Oct 14, 2015
86758d2
fix 0005
Jaccorot Oct 14, 2015
36cb92f
add 0022 and fix 0005
Jaccorot Oct 14, 2015
3cf2a0a
0006 -unfinished
Jaccorot Oct 14, 2015
218ea26
add 0006
Jaccorot Oct 15, 2015
a167447
add 0007
Jaccorot Oct 15, 2015
3dfa2da
add 0008
Jaccorot Oct 16, 2015
5af69c5
add 0009
Jaccorot Oct 16, 2015
d26c1dc
problem 0000 solved
vvzwvv Oct 16, 2015
d48a595
add 0010
Jaccorot Oct 16, 2015
3fbfb35
fix 0010
Jaccorot Oct 16, 2015
46bedbd
question 0001 solved
vvzwvv Oct 16, 2015
ae35c08
Merge pull request #149 from vvzwvv/master
horx Oct 16, 2015
51ed6e4
Merge branch 'master' of github.com:Jaccorot/python
Jaccorot Oct 17, 2015
64db1e4
Merge pull request #148 from Jaccorot/master
horx Oct 17, 2015
c820d61
add 0011
Jaccorot Oct 20, 2015
d6a2b8e
Merge branch 'master' of github.com:Jaccorot/python
Jaccorot Oct 21, 2015
ca6a28d
add 0012
Jaccorot Oct 21, 2015
8caa3bb
Merge branch 'master' of github.com:Jaccorot/python
Jaccorot Oct 22, 2015
c1160e3
fix 0011 0012
Jaccorot Oct 22, 2015
b9d9dda
add 0013
Jaccorot Oct 23, 2015
53ff213
第0013题
monkey-soft Oct 23, 2015
83c2b05
第0013题
monkey-soft Oct 23, 2015
b709d29
add 0014
Jaccorot Oct 25, 2015
9bff757
fix 0014,add 0015 0016
Jaccorot Oct 26, 2015
0837ba0
Merge pull request #150 from Jaccorot/master
horx Oct 27, 2015
eb89c63
add 0017 0018 0019
Jaccorot Oct 27, 2015
7352023
add 0020
Jaccorot Oct 28, 2015
c8d9d4c
add 0021
Jaccorot Oct 28, 2015
ad5391f
add 0023
Jaccorot Oct 28, 2015
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
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
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
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
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
0e6071b
Added files via upload
deng47 Mar 24, 2016
c936551
add AK-wang version
Mar 26, 2016
8e4df98
finish 0002
Mar 28, 2016
08aa514
clean code
Mar 28, 2016
c419ad0
finish 0003
Mar 29, 2016
6d3cc7f
add decorator version
Mar 30, 2016
2657765
pep8 style
Mar 30, 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
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.
31 changes: 31 additions & 0 deletions AK-wang/0006/key_word.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/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():
for txt in list_txt():
print wc(txt)

if __name__ == "__main__":
# most_comm()
print map(wc, list_txt())
29 changes: 29 additions & 0 deletions AK-wang/0011/filtered_words.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/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):
return (input_word in filtered_words(f_file))


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