Skip to content

Commit d7844f5

Browse files
committed
Merge pull request Show-Me-the-Code#168 from lwhhhh/master
add
2 parents 28460b3 + 2a37cbe commit d7844f5

File tree

6 files changed

+93
-6
lines changed

6 files changed

+93
-6
lines changed

lwh/10/captcha.jpg

6.53 KB
Loading

lwh/10/captcha.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
"""
2+
生成图片验证码
3+
"""
4+
import PIL
5+
import string
6+
import random
7+
from PIL import Image, ImageDraw, ImageFont, ImageFilter
8+
9+
image_path = "C:\\Users\\lwhil\\Desktop\\captcha.jpg"
10+
save_path = "C:\\Users\\lwhil\\Desktop\\captcha_f.jpg"
11+
font = ImageFont.truetype("C:/Windows/Fonts/Arial.ttf", 60)
12+
color = ["red", "black", "green", "blue", "yellow"]
13+
letters = string.ascii_letters
14+
15+
16+
def generate_captcha():
17+
image = Image.open(image_path)
18+
draw = ImageDraw.Draw(image)
19+
for i in range(1, 6):
20+
nums = str(random.randint(0, 9))
21+
width, height = image.size
22+
print(width, height)
23+
point = (50 + i * 100, 200 + random.randint(-100, 100))
24+
draw.text(point, nums, font=font, fill=color[random.randint(0, 4)])
25+
# image.rotate(90) #文档只有整张图片的倾斜效果,效果不好,不如不要
26+
27+
# 产生模糊效果
28+
GaussBlur = ImageFilter.GaussianBlur(radius=5)
29+
image = image.filter(GaussBlur)
30+
31+
image.save(save_path)
32+
33+
if __name__ == "__main__":
34+
generate_captcha()

lwh/10/captcha_f.jpg

7.54 KB
Loading

lwh/11/filter_word.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# coding = utf-8
2+
"""
3+
def filter_word():
4+
5+
# init
6+
filter_words_list = []
7+
with open("filtered_words.txt", "r") as f:
8+
string_read = f.readline()
9+
while string_read != "":
10+
filter_words_list.append(string_read)
11+
string_read = f.readline()
12+
13+
print("Enter \\q to exit.")
14+
string_input = input(
15+
"Input your word to check whether it was filtered ->")
16+
while string_input != "\\q":
17+
if string_input in filter_words_list:
18+
print("Freedom")
19+
else:
20+
print("Human Rights")
21+
string_input = input(
22+
"Input your word to check whether it was filtered ->")
23+
24+
if __name__ == "__main__":
25+
filter_word()
26+
27+
"""
28+
# coding = utf-8
29+
__author__ = 'Forec'
30+
word_filter = set()
31+
with open('filtered_words.txt',"r") as f:
32+
for x in f.readlines():
33+
word_filter |= {x.rstrip('\n')}
34+
while True:
35+
s = input()
36+
if s == 'exit':
37+
break
38+
elif s in word_filter:
39+
print('Freedom')
40+
else:
41+
print('Human Rights')
42+

lwh/11/filtered_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

lwh/7/line_counter.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,24 +32,24 @@ def isnote(line):
3232

3333
for filename in filenames:
3434
os.chdir(parent)
35-
print(filename)
36-
print(parent)
35+
# print(filename)
36+
# print(parent)
3737
with open(filename, "rb") as f:
3838
line = f.readline().strip()
3939
while line != b"":
40-
print("*")
40+
# print("*")
4141
ret = isnote(line)
42-
print(ret)
42+
# print(ret)
4343
if ret == "//":
4444
note_count = note_count + 1
4545
elif ret == "/*":
4646
line = f.readline().strip()
47-
print(line)
47+
# print(line)
4848
# if len(line) >= 2:
4949
while b"*/" in line:
5050
note_count = note_count + 1
5151
line = f.readline().strip()
52-
print(line)
52+
# print(line)
5353
elif ret == "no":
5454
code_count = code_count + 1
5555
line = f.readline().strip()

0 commit comments

Comments
 (0)