1212
task 0005 and 0006 added · feikon/python@2ac9bae · GitHub
Skip to content

Commit 2ac9bae

Browse files
committed
task 0005 and 0006 added
1 parent 5572040 commit 2ac9bae

File tree

5 files changed

+78
-0
lines changed

5 files changed

+78
-0
lines changed

Mr.Lin/0005/0005.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+
# -*- coding: utf-8 -*-
3+
# @Author: 30987
4+
# @Date: 2015-01-13 10:50:36
5+
# @Last Modified by: 30987
6+
# @Last Modified time: 2015-01-13 11:11:35
7+
# 第 0005 题:你有一个目录,装了很多照片,把它们的尺寸变成都不大于 iPhone5 分辨率的大小
8+
9+
from PIL import Image
10+
11+
12+
def change_img(path,size=(1136,640)):
13+
im = Image.open(path)
14+
size=(size[1],size[0]) if im.size[1]>im.size[0] else size
15+
im.thumbnail(size,Image.ANTIALIAS) #后一个参数为滤镜
16+
im.save('result-'+path)
17+
#im.show()
18+
19+
20+
if __name__ == '__main__':
21+
change_img('1.jpg')

Mr.Lin/0005/1.jpg

429 KB
Loading

Mr.Lin/0005/result-1.jpg

38.5 KB
Loading

Mr.Lin/0006/0006.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
# @Author: 30987
4+
# @Date: 2015-01-13 11:11:49
5+
# @Last Modified by: 30987
6+
# @Last Modified time: 2015-01-13 17:10:27
7+
8+
import re
9+
10+
def hot_words(file_path):
11+
file = open(file_path,'r')
12+
file_content = file.read()
13+
p = re.compile(r'[\W\d]*')
14+
word_list = p.split(file_content)
15+
16+
word_dict = {}
17+
for word in word_list:
18+
if word not in word_dict:
19+
word_dict[word] = 1
20+
else:
21+
word_dict[word] += 1
22+
sort = sorted(word_dict.items(), key=lambda e: e[1], reverse=True)
23+
sort = sorted(word_dict.items(), key=lambda e: e[1], reverse=True)
24+
25+
print("The most word in '%s' is '%s',it appears '%s' times" % (file_path,sort[1][0], sort[1][1]))
26+
27+
file.close()
28+
29+
30+
if __name__ == '__main__':
31+
hot_words('test.txt')

Mr.Lin/0006/test.txt

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
Why are my contributions not showing up on my profile?
2+
3+
4+
Contributions that are counted
5+
Your profile contributions graph is a record of contributions you've made to GitHub repositories. Contributions are only counted if they meet certain criteria. In some cases, we may need to rebuild your graph in order for contributions to appear.
6+
Issues and pull requests
7+
8+
Issues and pull requests will appear on your contributions graph if they meet both of these conditions:
9+
10+
They were opened within the past year.
11+
They were opened in a standalone repository, not a fork.
12+
Commits
13+
14+
Commits will appear on your contributions graph if they meet all of the following conditions:
15+
16+
The commits were made within the past year.
17+
The email address used for the commits is associated with your GitHub account.
18+
The commits were made in a standalone repository, not a fork.
19+
The commits were made:
20+
In the repository's default branch (usually master)
21+
In the gh-pages branch (for repositories with Project Pages sites)
22+
In addition, at least one of the following must be true:
23+
24+
You are a collaborator on the repository or are a member of the organization that owns the repository.
25+
You have forked the repository.
26+
You have opened a pull request or issue in the repository.

0 commit comments

Comments
 (0)