Skip to content

Commit 1c78783

Browse files
committed
Merge remote-tracking branch 'smc/master'
2 parents c854acc + d59f0e2 commit 1c78783

52 files changed

Lines changed: 1122 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

agmcs/0000/0000.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from PIL import Image, ImageDraw, ImageFont
2+
text = "52"
3+
im = Image.open('1.bmp')
4+
w,h = im.size
5+
font_size = h//4
6+
7+
draw = ImageDraw.Draw(im)
8+
font = ImageFont.truetype ("Arial.ttf",font_size)
9+
10+
text_w,text_h = draw.textsize(text,font=font)
11+
draw.text((w-text_w,0), text, fill=(255,0,0), font=font)
12+
13+
14+
im.save('heihei.bmp')

agmcs/0000/1.bmp

1.02 MB
Binary file not shown.

agmcs/0001/0001.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import uuid
2+
3+
uuids = []
4+
for i in range(200):
5+
uuids.append(uuid.uuid1())
6+
print uuids

agmcs/0004/0004.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import re
2+
with open('test.txt','r')as f:
3+
data = f.read()
4+
result = re.split(r"[^a-zA-Z]",data)
5+
print len([x for x in result if x!= ''])

agmcs/0004/test.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Henry was a pen name used by an American writer of short stories. His real name was William Sydney Porter. He was born in North Carolina in 1862. As a young boy he lived an exciting life. He did not go to school for very long, but he managed to teach himself everything he needed to know. When he was about 20 years old, O. Henry went to Texas, where he tried different jobs. He first worked on a newspaper, and then had a job in a bank, when some money went missing from the bank O. Henry was believed to have stolen it. Because of that, he was sent to prison. During the three years in prison, he learned to write short stories. After he got out of prison, he went to New York and continued writing. He wrote mostly about New York and the life of the poor there. People liked his stories, because simple as the tales were, they would finish with a sudden change at the end, to the reader��s surprise.

agmcs/0005/0005.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import os
2+
from PIL import Image
3+
4+
def resize(path):
5+
im = Image.open(path)
6+
w,h = im.size
7+
if w>640:
8+
x = w/640.0
9+
w=640
10+
h = int(h//x)
11+
if h>1136:
12+
x = h/1136.0
13+
h=1136
14+
w = int(w//x)
15+
print w,h
16+
im = im.resize((w,h),Image.ANTIALIAS)
17+
im.show()
18+
im.save(path)
19+
20+
path = 'img/'
21+
dirlist = os.listdir(path)
22+
23+
for img in dirlist:
24+
abspath = os.path.join(path,img)
25+
if os.path.isfile(abspath):
26+
resize(abspath)
563 KB
Loading

agmcs/0005/img/1.jpg

247 KB
Loading
429 KB
Loading

agmcs/0006/0006.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import os,re
2+
path = 'test/'
3+
dirlist = os.listdir(path)
4+
5+
for x in dirlist:
6+
abspath = os.path.join(path,x)
7+
if os.path.isfile(abspath):
8+
if os.path.splitext(abspath)[1] == '.txt':
9+
with open(abspath,'r')as f:
10+
data = f.read()
11+
result = re.split(r'[^a-zA-Z]', data)
12+
words = [x for x in result if x!='']
13+
items = dict([(i,words.count(i)) for i in words])
14+
items = sorted(items.iteritems(),key =lambda d:d[1],reverse = True)
15+
print abspath,'中出现最多的是',items[0][0],'出现了',items[0][1],'次',',其次是',items[1][0],'出现了',items[1][1],'次'
16+

0 commit comments

Comments
 (0)