Skip to content

Commit 3ffcf2e

Browse files
committed
task 0007 added
1 parent 68177d3 commit 3ffcf2e

File tree

3 files changed

+72
-0
lines changed

3 files changed

+72
-0
lines changed

Mr.Lin/0000/Thumbs.db

-32 KB
Binary file not shown.

Mr.Lin/0007/0000.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
# @Author: 30987
4+
# @Date: 2015-01-12 16:06:03
5+
# @Last Modified by: 30987
6+
# @Last Modified time: 2015-01-12 17:03:30
7+
#将你的 QQ 头像(或者微博头像)右上角加上红色的数字,类似于微信未读信息数量那种提示效果。
8+
9+
from PIL import Image, ImageDraw, ImageFont
10+
class Image_unread_message:
11+
def open(self,path):
12+
self.im=Image.open(path)
13+
return True
14+
def __init__(self):
15+
self.fnt=None
16+
self.im=None
17+
18+
def setFont(self,font_path,size):
19+
self.fnt=ImageFont.truetype(font_path,size)
20+
return True
21+
def draw_text(self,position,str,colour,fnt):
22+
draw=ImageDraw.Draw(self.im)
23+
draw.text(position,str,fill=colour,font=fnt)
24+
self.im.show()
25+
self.im.save(str+'num'+'.jpg')
26+
return True
27+
28+
29+
test=Image_unread_message()
30+
test.open('1.png')
31+
test.setFont('ahronbd.ttf',80)
32+
test.draw_text((200,-20),'4',(255,0,0),test.fnt)
33+

Mr.Lin/0007/0007.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
# @Author: 30987
4+
# @Date: 2015-01-14 11:07:02
5+
# @Last Modified by: 30987
6+
# @Last Modified time: 2015-01-14 11:47:11
7+
#第 0007 题:有个目录,里面是你自己写过的程序,统计一下你写过多少行代码。包括空行和注释,但是要分别列出来。
8+
#
9+
#
10+
11+
"""
12+
此处统计的注释行# 并不会将#!/usr/bin/env python # -*- coding: utf-8 -*- 统计在内,同时if __main__里面的注释也不会进行统计
13+
14+
15+
def code_count(code_file):
16+
total_lines = 0
17+
empty_lines = 0
18+
comment_lines = 0
19+
20+
file_object = open(code_file,'r')
21+
for line in file_object:
22+
word_list = line.split()
23+
#print word_list
24+
if word_list == []:
25+
empty_lines += 1
26+
elif word_list[0] == '#':
27+
comment_lines += 1
28+
total_lines += 1
29+
30+
file_object.close()
31+
#print("Total line: %s. Empty lines :%s.Comment lines:%s"% (total_lines,empty_lines,comment_lines))
32+
return total_lines,empty_lines,comment_lines
33+
34+
35+
if __name__ == '__main__':
36+
t,e,c=code_count('0007.py')
37+
print("Total line: %s. Empty lines :%s.Comment lines:%s"%(t,e,c))
38+
39+

0 commit comments

Comments
 (0)