Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added A1014280203/0/0.1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added A1014280203/0/0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions A1014280203/0/0.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from PIL import Image, ImageFont, ImageDraw

image = Image.open('0.png')
w, h = image.size
font = ImageFont.truetype('arial.ttf', 50)
draw = ImageDraw.Draw(image)
draw.text((4*w/5, h/5), '5', fill=(255, 10, 10), font=font)
image.save('0.0.png', 'png')
41 changes: 41 additions & 0 deletions A1014280203/1/1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import base64

# base64编码方便使用

# 通过id检验优惠券是否存在,通过goods查找商品
coupon = {
'id': '1231',
'goods': '0001',
}


def gen_coupon(id, goods):
coupon['id'] = id
coupon['goods'] = goods
raw = '/'.join([k + ':' + v for k, v in coupon.items()])
raw_64 = base64.urlsafe_b64encode(raw.encode('utf-8'))
c_code = raw_64.decode()
return c_code


def save_coupon(c_code):
with open('coupon.txt', 'a+') as file:
file.write(c_code+'\n')


def show_coupon(c_code):
print('优惠码:', c_code)


def parse_coupon(c_code):
print('解析优惠码:', base64.urlsafe_b64decode(c_code.encode('utf-8')))


def gen_all():
for i in range(1000, 1200):
c_code = gen_coupon(str(i), str(int(i/2)))
save_coupon(c_code)


if __name__ == '__main__':
gen_all()
Loading