Skip to content

Commit 2be7775

Browse files
authored
Merge pull request Show-Me-the-Code#241 from StevenLianaL/master
wangzhou 0000 answer
2 parents fee767d + 45a3f02 commit 2be7775

File tree

5 files changed

+41
-0
lines changed

5 files changed

+41
-0
lines changed

WangZhou/0000/consolab.ttf

375 KB
Binary file not shown.

WangZhou/0000/insert_num_angle.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
from PIL import Image, ImageDraw, ImageFont
2+
3+
4+
def insert_angle_num(img):
5+
"""
6+
Insert a num on the right-upper angle,then save the new image.
7+
:param img:string : filename of an Image object
8+
"""
9+
with Image.open(img) as im:
10+
width, height = im.size
11+
draw_image = ImageDraw.Draw(im)
12+
color = '#ff0000'
13+
num_font = ImageFont.truetype('consolab.ttf', 100)
14+
draw_image.text((width - 80, 20), '7', font=num_font, fill=color)
15+
im.save('new_message.jpg')
16+
17+
18+
if __name__ == "__main__":
19+
img = 'wz0000.jpg'
20+
insert_angle_num(img)

WangZhou/0000/new_message.jpg

40.2 KB
Loading

WangZhou/0000/wz0000.jpg

41.7 KB
Loading

WangZhou/0001/gen_act_key.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import uuid
2+
3+
4+
def gen_act_key(n):
5+
"""
6+
生成 n 个激活码,保存在字典。
7+
:param n: int
8+
:return: dict
9+
"""
10+
act_code_store = {}
11+
12+
for i in range(n):
13+
code0 = str(uuid.uuid1()).split('-')[0]
14+
code1 = '-'.join(str(uuid.uuid3(uuid.NAMESPACE_DNS, f'{i}')).split('-')[1:])
15+
act_code = code0 + '-' + code1
16+
act_code_store[f'id-{i}'] = act_code
17+
return act_code_store
18+
19+
20+
if __name__ == "__main__":
21+
activity_code = gen_act_key(200)

0 commit comments

Comments
 (0)