Skip to content

Commit aaf8c76

Browse files
committed
2 parents 4665087 + f4f2b5a commit aaf8c76

File tree

7 files changed

+82
-0
lines changed

7 files changed

+82
-0
lines changed

.DS_Store

2 KB
Binary file not shown.

xianhuan/.DS_Store

4 KB
Binary file not shown.

xianhuan/circlegame/circlegame.py

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#!/usr/bin/env python3
2+
# -*- coding: utf-8 -*-
3+
"""
4+
@author: 闲欢
5+
"""
6+
import pygame, random, sys, time
7+
8+
pygame.init()
9+
screen = pygame.display.set_mode([600, 400])
10+
screen.fill((255, 255, 255))
11+
# 圆的半径
12+
radius = [0] * 10
13+
# 圆的半径增量
14+
circleDelt = [0] * 10
15+
# 圆是否存在,False代表该索引值下的圆不存在,True代表存在
16+
circleExists = [False] * 10
17+
# 圆的坐标x轴
18+
circleX = [0] * 10
19+
# 圆的坐标y轴
20+
circleY = [0] * 10
21+
# 颜色RGB值
22+
RGBx = [0] * 10
23+
RGBy = [0] * 10
24+
RGBz = [0] * 10
25+
26+
while True:
27+
# 停顿0.1秒
28+
time.sleep(0.1)
29+
for event in pygame.event.get():
30+
# 鼠标按下
31+
if event.type == pygame.MOUSEBUTTONDOWN:
32+
# 获取圆不存在的索引值
33+
num = circleExists.index(False)
34+
# 将该索引值的圆设置为存在
35+
circleExists[num] = True
36+
# 圆的半径设置为0
37+
radius[num] = 0
38+
# 获取鼠标坐标
39+
circleX[num], circleY[num] = pygame.mouse.get_pos()
40+
# 随机获取颜色值
41+
RGBx[num] = random.randint(0, 255)
42+
RGBy[num] = random.randint(0, 255)
43+
RGBz[num] = random.randint(0, 255)
44+
# 画圆
45+
pygame.draw.circle(screen, pygame.Color(RGBx[num], RGBy[num], RGBz[num]),
46+
(circleX[num], circleY[num]), radius[num], 1)
47+
if event.type == pygame.QUIT:
48+
pygame.quit()
49+
sys.exit()
50+
for i in range(10):
51+
# 圆不存在则跳过循环
52+
if not circleExists[i]:
53+
pass
54+
else:
55+
# 随机圆的大小
56+
if radius[i] < random.randint(10, 50):
57+
# 圆的随机半径增量
58+
circleDelt[i] = random.randint(0, 5)
59+
radius[i] += circleDelt[i]
60+
# 画圆
61+
pygame.draw.circle(screen, pygame.Color(RGBx[i], RGBy[i], RGBz[i]),
62+
(circleX[i], circleY[i]), radius[i], 1)
63+
else:
64+
# 若圆已达到最大,这将该索引值的圆设置为不存在
65+
circleExists[i] = False
66+
pygame.display.update()

yeke/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
+ [py-minesweep](https://github.com/JustDoPython/python-examples/tree/master/yeke/py-minesweep) :用 Python 实现扫雷小游戏
1919
+ [py-ascii](https://github.com/JustDoPython/python-examples/tree/master/yeke/py-ascii) :Python 实现图片转字符画,静态图、GIF 都能转
2020
+ [py-snow](https://github.com/JustDoPython/python-examples/tree/master/yeke/py-snow) :用 Python 实现带音乐的雪花飘落雪景图
21+
+ [py-discern](https://github.com/JustDoPython/python-examples/tree/master/yeke/py-discern) :十行 Python 代码就提取了韦小宝的身份证信息
2122

2223
---
2324

yeke/py-discern/__init__.py

Whitespace-only changes.

yeke/py-discern/card.jpg

144 KB
Loading

yeke/py-discern/idcard_discern.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from aip import AipOcr
2+
3+
APP_ID = ''
4+
API_KEY = ''
5+
SECRET_KEY = ''
6+
# 创建客户端对象
7+
client = AipOcr(APP_ID, API_KEY, SECRET_KEY)
8+
# 打开并读取文件内容
9+
fp = open("card.jpg", "rb").read()
10+
# res = client.basicGeneral(fp) # 普通
11+
res = client.basicAccurate(fp) # 高精度
12+
# 遍历结果
13+
for tex in res["words_result"]:
14+
row = tex["words"]
15+
print(row)

0 commit comments

Comments
 (0)