Skip to content

Commit 21797aa

Browse files
committed
fybhp's code
1 parent c7e043b commit 21797aa

70 files changed

Lines changed: 2874 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

fybhp/.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.idea
2+
fortest.py
3+
*.png
4+
*.jpg
5+
migrations
6+
*.sqlite
7+
*.pyc

fybhp/practice0/practice0.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# -*- coding:utf-8 -*-
2+
import PIL
3+
from PIL import ImageFont
4+
from PIL import Image
5+
from PIL import ImageDraw
6+
7+
#设置字体,如果没有,也可以不设置
8+
#font = ImageFont.truetype("/usr/share/fonts/truetype/ttf-dejavu/DejaVuSans.ttf",13)
9+
10+
#打开底版图片
11+
imageFile = "./icon.jpg"
12+
im1=Image.open(imageFile)
13+
14+
# 在图片上添加文字 1
15+
draw = ImageDraw.Draw(im1)
16+
draw.text((90, 5),"2",(255,0,0))#,font=font)
17+
draw = ImageDraw.Draw(im1)
18+
19+
# 保存
20+
im1.save("./practice1/icon.png")

fybhp/practice1/practice1.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# -*- coding:utf-8 -*-
2+
import re
3+
import string
4+
import random
5+
6+
map = {}
7+
#pattern = re.compile(r'([a-z0-9A-Z]{4}-){3}([a-z0-9A-Z]{4})')
8+
#这个函数定义的很精髓
9+
def id_generator(size=4, chars=string.ascii_uppercase + string.digits + string.ascii_lowercase):
10+
#[random.choice(chars) for _ in range(size)]为列表解析
11+
#(random.choice(chars) for _ in range(size))为生成器,其对内存更友好
12+
list = []
13+
for i in range(4):
14+
a = ''.join(random.choice(chars) for _ in range(size))
15+
list.append(a)
16+
return list
17+
for i in range(200):
18+
id = '-'.join(id_generator())
19+
while id in map.values():
20+
id = '-'.join(id_generator())
21+
map[i] = id
22+
print map

fybhp/practice10/arial.ttf

304 KB
Binary file not shown.

fybhp/practice10/practice10.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# -*- coding:utf-8 -*-
2+
import string
3+
import random
4+
from PIL import Image,ImageDraw,ImageFont,ImageFilter
5+
6+
def numgenerator(size=4, chars=string.ascii_uppercase + string.digits + string.ascii_lowercase):
7+
return ''.join(random.choice(chars) for _ in range(size))
8+
9+
def getcolor():
10+
return (random.randint(0,255),random.randint(0,255),random.randint(0,255))
11+
12+
def getfont():
13+
font = ImageFont.truetype('Arial.ttf',random.randint(50,65))
14+
return font
15+
16+
check = numgenerator()
17+
imageFile = "./bacdgroud.jpg"
18+
img = Image.open(imageFile)
19+
draw = ImageDraw.Draw(img)
20+
for i in range(4):
21+
draw.text((72*i+random.randint(15,20), random.randint(5,10)),check[i],getcolor(),font=getfont())
22+
draw = ImageDraw.Draw(img)
23+
image = img.filter(ImageFilter.BLUR)
24+
25+
image.save("./test1.jpg")

fybhp/practice11/filter_words.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
����
2+
����Ա
3+
����Ա
4+
�쵼
5+
ţ��
6+
ţ��
7+
����
8+
����
9+
love
10+
sex
11+
jiangge

fybhp/practice11/practice11.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# -*- coding:utf-8 -*-
2+
3+
list = []
4+
file = open('filter_words.txt','r')
5+
content = file.read().decode('gbk')
6+
allwords = content.split()
7+
#print allwords
8+
checkword = raw_input('>').decode('utf-8')
9+
if checkword in allwords:
10+
print 'Freedom'
11+
else:
12+
print 'Hunam Rights'

fybhp/practice12/filter_words.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
����
2+
����Ա
3+
����Ա
4+
�쵼
5+
ţ��
6+
ţ��
7+
����
8+
����
9+
love
10+
sex
11+
jiangge

fybhp/practice12/practice12.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# -*- coding:utf-8 -*-
2+
import re
3+
list = []
4+
file = open('filter_words.txt','r')
5+
content = file.read().decode('gbk')
6+
allwords = content.split()
7+
#print allwords
8+
yourword = raw_input('>').decode('utf-8')
9+
for mingan in allwords:
10+
if mingan in yourword:
11+
yourword = re.sub(mingan,'*'*len(mingan),yourword)
12+
print yourword

fybhp/practice13/practice13/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)