Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

0000 #2

Open
wants to merge 36 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
8d714ce
Create 0000
ybcc2015 Mar 23, 2016
4af7686
Update 0000
ybcc2015 Mar 23, 2016
99fc31a
Added files via upload
ybcc2015 Mar 23, 2016
63bc2e1
Delete result.jpg
ybcc2015 Mar 23, 2016
a57c123
Delete pic.jpg
ybcc2015 Mar 23, 2016
cf3bba8
Added files via upload
ybcc2015 Mar 23, 2016
773a4fb
Delete pic.jpg
ybcc2015 Mar 23, 2016
5a3d3fa
Added files via upload
ybcc2015 Mar 23, 2016
1eca699
Rename 0000 to 0000.py
ybcc2015 Mar 28, 2016
1ff73ce
Create 0002.py
ybcc2015 Mar 28, 2016
ad14d50
Added files via upload
ybcc2015 Mar 28, 2016
56ac2b8
Rename 0000.py to 0000/0000.py
ybcc2015 Mar 28, 2016
5e4418a
Delete Futura.ttf
ybcc2015 Mar 28, 2016
e36e5cf
Delete pic.jpg
ybcc2015 Mar 28, 2016
6742947
Delete result.jpg
ybcc2015 Mar 28, 2016
e86e7a1
Added files via upload
ybcc2015 Mar 28, 2016
b3cdf1e
Create 0001.py
ybcc2015 Mar 28, 2016
a3849ee
Added files via upload
ybcc2015 Mar 28, 2016
6616b8a
Update 0002.py
ybcc2015 Mar 28, 2016
664df04
Create 0004.py
ybcc2015 Mar 28, 2016
7b30009
Added files via upload
ybcc2015 Mar 28, 2016
76c98f7
Create 0005.py
ybcc2015 Mar 29, 2016
882f4e0
Create 0006.py
ybcc2015 Mar 30, 2016
7880958
Added files via upload
ybcc2015 Mar 30, 2016
4dde756
Create 0007.py
ybcc2015 Apr 4, 2016
2a44d83
Added files via upload
ybcc2015 Apr 4, 2016
92808cb
Rename 0007/test1.py to 0007/codes/codes1.py
ybcc2015 Apr 4, 2016
bd0f8cf
Rename 0007/test2.py to 0007/codes/codes2.py
ybcc2015 Apr 4, 2016
0f8f860
Create 0010.py
ybcc2015 Apr 4, 2016
674e21a
Added files via upload
ybcc2015 Apr 4, 2016
8173570
Update 0010.py
ybcc2015 Apr 4, 2016
b0a63be
Create 0011.py
ybcc2015 Apr 5, 2016
1743122
Added files via upload
ybcc2015 Apr 5, 2016
80d1c14
Create 0012.py
ybcc2015 Apr 6, 2016
e4dfaf7
Create 0008.py
ybcc2015 Apr 8, 2016
0cc7fe4
Create 0009.py
ybcc2015 Apr 8, 2016
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
20 changes: 20 additions & 0 deletions 0000/0000.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
'''
在你的头像上加上数字,像微信的消息提示一样。
'''
from PIL import Image,ImageFont,ImageDraw
import random

def add_num(image_path):
img=Image.open(image_path)
x,y=img.size #得到头像的宽和高
draw=ImageDraw.Draw(img)
text=str(random.randint(1,99)) #产生随机数字并字符化
myfont=ImageFont.truetype('Futura.ttf',100) #初始text的字体类型和尺寸
draw.text((x*3/4,0),text,font=myfont,fill='red') #修改图像

img.save('result.jpg','jpeg') #保存

if '__name__'=='__main__':
add_num('pic.jpg')

Binary file added 0000/Futura.ttf
Binary file not shown.
Binary file added 0000/pic.jpg
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 0000/result.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 28 additions & 0 deletions 0001/0001.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env python
#-*- coding: utf-8 -*-

'''生成200个长度为6的随机码'''

import random,string

#生成随机码
def generateCodes(code_amount,code_len):
Strs=string.digits+string.letters
codes=[]
while(code_amount>0):
code=''.join([random.choice(Strs) for i in range(code_len)])
if code not in codes:
code+='\n'
codes.append(code)
code_amount-=1
return codes

#将随机码写入codes.txt
def file_write(code_amount,code_len):
f=open('codes.txt','w')
for code in generateCodes(code_amount,code_len):
f.write(code)
f.close()

if __name__=='__main__':
file_write(200,6)
200 changes: 200 additions & 0 deletions 0001/codes.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,200 @@
TgPBxf
CVowQf
3geks8
C39x3H
asH2cO
ep77Sz
L4LXqC
eLESID
FmMU9Y
AXWzNa
JDeiTS
0iK5yg
8M82Hk
wPsXqs
4HqdvX
9NTGrC
1vcmsr
dwbtWU
FspcuB
Xjvt6j
cWU8nc
MVcDlL
Rscydc
dAPTb3
tFsY5X
scplD2
GlcOIC
CF5iYb
4enhxh
G8JHXo
C4Hg1m
TRpJyp
u70BSQ
kxzpHM
27rbMo
wbfhKe
4AtXQf
msXapJ
hDwi45
O94zet
Fn9iL2
DaGRIW
8e7Nje
fuGWr7
PgNyBh
aodJiZ
1yAqTt
asySdM
cxyVRp
pzQihk
4kdUWF
QjbSSg
vx0nSu
QW7CHb
hLHU6K
tjlpCA
a7myrr
CEhXox
II8Zis
OfeFPS
Kufn4p
raYXEj
P30UDq
NCGjuS
rjly2n
R9VVhY
U2zUJa
WqpCvB
S3e1jC
VRlvgM
7JNuxW
3dQS6n
y4EBt2
WHMnuj
v17BOt
MgSqcA
tFlG84
3t6bOM
MmEoos
VYyZZe
8zcayM
uhAisc
kNJP5r
gVxHKY
DyrX3j
ZGVVaw
5sYHyW
YvbBJh
wBrtLl
9vcOIC
Twww7u
9KFuQS
fc8ew9
ibtWFT
CZMwx1
KThLy6
oV3bPx
TJP2qN
xC9k4V
lopHZW
C3rSPX
JpWpmS
iOTmZK
Rx7fAL
IWo6Nw
78ky9O
ZFDtTg
Sya00v
mi3JiK
xFL6qr
mkvuVp
27Xhbj
7VP3pN
NEex7s
GFtkQh
eI4ZHD
1md6Ic
zqXka7
WJ6Z1Q
D8o2Hm
ti9GAm
yx7Qza
mHpgLm
scqKkT
2nXgJk
McuxGq
h81m6b
YQwNEz
5AbGOk
cjuNpX
k2eZXi
hjifpP
VdA8kn
8YodQm
PbNST6
ZhuBzC
z8n3pW
Hf4QeY
gZKugx
EUaHan
qeRz11
dpXPow
Iz8KI1
FZsGYk
4t0DRM
ILroFm
jkGSdF
m8duxP
BjguYn
ceKOHq
XqFIQK
e5kwXM
MN7Pbt
BOtcpc
TRPtgu
Ye02Oa
utKUZa
FRAyEJ
5Fx6XB
zZznzk
FxhJMy
WcF9WX
2aUaWN
alVYGH
OH4VpS
U3GDTz
3pvi9S
L6TA6F
XUhihY
8v65Cm
tWogs3
NXAc3j
D0oJ3I
C8Zv52
Hte3mo
4sOLRT
BFUtkA
aZtMED
oEb8il
jO9Eu5
0Hj646
9r1X2g
hGnNVd
srGsiQ
Skja0g
fkFIMY
IiOAp5
PVGMn6
8k6c8e
a49vkH
oH8CEw
ivQNAl
d2nUpu
ihkj27
P19Fj8
SidKm8
8LXLPq
xQwvLp
hdop4B
MbHqZK
33 changes: 33 additions & 0 deletions 0002/0002.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

'''将随机码存入mysql'''

import mysql.connector

#读取文件
def file_read(filename):
#从文件中读取每行的码
codes=[]
with open(filename,'r') as f:
lines=f.readlines()
for n in range(200):
#去除每行的空白符
codes.append(lines[n].strip())
return codes

#存入数据库
def store():
codes=file_read('codes.txt')
conn=mysql.connector.connect(user='root',password='666666',database='test',use_unicode=True)
cursor=conn.cursor()
cursor.execute('create table codes(id int(3) primary key,code varchar(6))')
for n in range(200):
cursor.execute('insert into codes (id,code) values (%s,%s)',[n+1,codes[n]])
conn.commit()
cursor.close()
conn.close()
print 'finish'

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