Skip to content

Commit f6287cc

Browse files
committed
0011-0022
1 parent 30c3bef commit f6287cc

File tree

27 files changed

+244
-0
lines changed

27 files changed

+244
-0
lines changed

NKUCodingCat/0011/0011.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import os,re
2+
ex = re.split("[\r\n]+",unicode(open(os.path.split(os.path.realpath(__file__))[0]+"/filtered_words.txt").read().decode("GBK")))
3+
while True:
4+
input = raw_input()
5+
if input == "":
6+
break
7+
else:
8+
try:
9+
input = unicode(input)
10+
except:
11+
try:
12+
input = unicode(input.decode("utf-8"))
13+
except:
14+
try:
15+
input = unicode(input.decode("GBK"))
16+
except:
17+
raise "Unknown Codec"
18+
input = re.split("\s+",input)
19+
Flag = True
20+
for i in input:
21+
if i in ex:
22+
print "Human Rights"
23+
Flag = False
24+
break
25+
if Flag:
26+
print "Freedom"
27+
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

NKUCodingCat/0012/0012.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import os,re
2+
ex = re.split("[\r\n]+",unicode(open(os.path.split(os.path.realpath(__file__))[0]+"/filtered_words.txt").read().decode("GBK")))
3+
Find = re.compile("("+("%s|"*len(ex)%tuple(ex))[:-1]+")")
4+
while True:
5+
input = raw_input()
6+
if input == "":
7+
break
8+
else:
9+
try:
10+
input = unicode(input)
11+
except:
12+
try:
13+
input = unicode(input.decode("utf-8"))
14+
except:
15+
try:
16+
input = unicode(input.decode("GBK"))
17+
except:
18+
raise "Unknown Codec"
19+
print Find.sub("**",input)
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

NKUCodingCat/0013/0013.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import requests,os,re,urllib
2+
from lxml import etree
3+
src = requests.get("""http://tieba.baidu.com/p/2166231880""").content
4+
path = os.path.split(os.path.realpath(__file__))[0]+"/img/"
5+
for i in etree.HTML(src.decode('utf-8', 'ignore')).xpath(u"//img"):
6+
url = i.attrib["src"]
7+
proto, rest = urllib.splittype(url)
8+
host, rest = urllib.splithost(rest)
9+
if host == "imgsrc.baidu.com":
10+
urllib.urlretrieve(url, path+os.path.split(url)[1])

NKUCodingCat/0014/0014.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#coding=utf-8
2+
import json, xlwt, os
3+
f = open(os.path.split(os.path.realpath(__file__))[0]+"/student.txt")
4+
dict = json.loads(f.read().decode("GBK"))
5+
xls = xlwt.Workbook()
6+
sheet = xls.add_sheet("student")
7+
for i in range(len(dict.keys())):
8+
row = i
9+
col = 0
10+
sheet.write(row, col, dict.keys()[i])
11+
for j in (dict[dict.keys()[i]]):
12+
col+=1
13+
sheet.write(row, col, j )
14+
xls.save(os.path.split(os.path.realpath(__file__))[0]+"/student.xls")

NKUCodingCat/0014/student.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"1":["����",150,120,100],
3+
"2":["����",90,99,95],
4+
"3":["����",60,66,68]
5+
}

NKUCodingCat/0014/student.xls

5.5 KB
Binary file not shown.

NKUCodingCat/0015/0015.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#coding=utf-8
2+
import json, xlwt, os
3+
f = open(os.path.split(os.path.realpath(__file__))[0]+"/city.txt")
4+
dict = json.loads(f.read().decode("GBK"))
5+
xls = xlwt.Workbook()
6+
sheet = xls.add_sheet("city")
7+
for i in range(len(dict.keys())):
8+
row = i
9+
col = 0
10+
sheet.write(row, col, dict.keys()[i])
11+
sheet.write(row, col+1, dict[dict.keys()[i]])
12+
xls.save(os.path.split(os.path.realpath(__file__))[0]+"/city.xls")

NKUCodingCat/0015/city.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"1" : "�Ϻ�",
3+
"2" : "����",
4+
"3" : "�ɶ�"
5+
}

0 commit comments

Comments
 (0)