https://github.com/ZTCooper/show-me-the-code by ZTCooper · Pull Request #252 · Show-Me-the-Code/python

3 changes: 3 additions & 0 deletions .gitmodules

Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[submodule "JiYouMCC"]
path = JiYouMCC
url = https://github.com/JiYouMCC/python-show-me-the-code
[submodule "cnwangjie"]
path = cnwangjie
url = https://github.com/cnwangjie/practice-go

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()