X Tutup
Skip to content

Commit 68177d3

Browse files
committed
0000-0006 added
1 parent 2ac9bae commit 68177d3

File tree

8 files changed

+153
-0
lines changed

8 files changed

+153
-0
lines changed

Mr.Lin/0000/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/0000/1.png

75.9 KB
Loading

Mr.Lin/0000/Thumbs.db

32 KB
Binary file not shown.

Mr.Lin/0001/0001.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
# @Author: 30987
4+
# @Date: 2015-01-12 17:03:52
5+
# @Last Modified by: 30987
6+
# @Last Modified time: 2015-01-12 17:21:29
7+
8+
#第 0001 题:做为 Apple Store App 独立开发者,你要搞限时促销,为你的应用生成激活码(或者优惠券),使用 Python 如何生成 200 个激活码(或者优惠券)?
9+
10+
11+
import uuid
12+
13+
def creat_code(number=10):
14+
result =[]
15+
16+
while True is True:
17+
uuid_id=uuid.uuid1()
18+
tem = str(uuid_id).replace('-','')
19+
tmmmm=str(tem[4:])
20+
if not tmmmm in result:
21+
result.append(tmmmm)
22+
if len(result) is number:
23+
break
24+
print result
25+
26+
creat_code()

Mr.Lin/0002/0002.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
# @Author: 30987
4+
# @Date: 2015-01-12 17:22:35
5+
# @Last Modified by: 30987
6+
# @Last Modified time: 2015-01-12 22:33:53
7+
8+
#第 0002 题:将 0001 题生成的 200 个激活码(或者优惠券)保存到 MySQL 关系型数据库中。
9+
10+
import uuid
11+
import MySQLdb
12+
13+
def creat_code(number=20):
14+
result = []
15+
while True is True:
16+
tem=str(uuid.uuid1()).replace('-','')
17+
if not tem in result:
18+
result.append(tem)
19+
if len(result) is number:
20+
break
21+
return result
22+
23+
def coont_db(result):
24+
num = len(result)
25+
db= MySQLdb.connect('localhost','root','','python',charset='utf8')
26+
cur = db.cursor()
27+
28+
try:
29+
db= MySQLdb.connect('localhost','root','','python',charset='utf8')
30+
cur = db.cursor()
31+
print "OK"
32+
for i in xrange(num):
33+
cur.execute('insert into code (code_num) values("%s")' % (result[i]))
34+
db.commit()
35+
except:
36+
print "数据库连接错误!"
37+
db.rollback()
38+
db.close()
39+
40+
41+
42+
if __name__ == '__main__':
43+
coont_db(creat_code())

Mr.Lin/0004/0004.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
# @Author: 30987
4+
# @Date: 2015-01-12 22:58:23
5+
# @Last Modified by: 30987
6+
# @Last Modified time: 2015-01-12 23:09:12
7+
8+
#第 0004 题:任一个英文的纯文本文件,统计其中的单词出现的个数。
9+
10+
def word_count(file_path):
11+
file = open(file_path,'r')
12+
num = 0
13+
file.read()
14+
for line in file:
15+
line_list = line.split()
16+
#print line_list
17+
num += len(line_list)
18+
file.close()
19+
return num
20+
21+
if __name__ == '__main__':
22+
try:
23+
print 'The total number of words is :',word_count('test.txt')
24+
except Exception, e:
25+
print "Can't open file!"

Mr.Lin/0004/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.

Mr.Lin/0005/Thumbs.db

8 KB
Binary file not shown.

0 commit comments

Comments
 (0)
X Tutup