Skip to content
Merged

add #168

Show file tree
Hide file tree
Changes from all commits
Commits
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
Binary file added lwh/10/captcha.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions lwh/10/captcha.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
"""
生成图片验证码
"""
import PIL
import string
import random
from PIL import Image, ImageDraw, ImageFont, ImageFilter

image_path = "C:\\Users\\lwhil\\Desktop\\captcha.jpg"
save_path = "C:\\Users\\lwhil\\Desktop\\captcha_f.jpg"
font = ImageFont.truetype("C:/Windows/Fonts/Arial.ttf", 60)
color = ["red", "black", "green", "blue", "yellow"]
letters = string.ascii_letters


def generate_captcha():
image = Image.open(image_path)
draw = ImageDraw.Draw(image)
for i in range(1, 6):
nums = str(random.randint(0, 9))
width, height = image.size
print(width, height)
point = (50 + i * 100, 200 + random.randint(-100, 100))
draw.text(point, nums, font=font, fill=color[random.randint(0, 4)])
# image.rotate(90) #文档只有整张图片的倾斜效果,效果不好,不如不要

# 产生模糊效果
GaussBlur = ImageFilter.GaussianBlur(radius=5)
image = image.filter(GaussBlur)

image.save(save_path)

if __name__ == "__main__":
generate_captcha()
Binary file added lwh/10/captcha_f.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
42 changes: 42 additions & 0 deletions lwh/11/filter_word.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# coding = utf-8
"""
def filter_word():

# init
filter_words_list = []
with open("filtered_words.txt", "r") as f:
string_read = f.readline()
while string_read != "":
filter_words_list.append(string_read)
string_read = f.readline()

print("Enter \\q to exit.")
string_input = input(
"Input your word to check whether it was filtered ->")
while string_input != "\\q":
if string_input in filter_words_list:
print("Freedom")
else:
print("Human Rights")
string_input = input(
"Input your word to check whether it was filtered ->")

if __name__ == "__main__":
filter_word()

"""
# coding = utf-8
__author__ = 'Forec'
word_filter = set()
with open('filtered_words.txt',"r") as f:
for x in f.readlines():
word_filter |= {x.rstrip('\n')}
while True:
s = input()
if s == 'exit':
break
elif s in word_filter:
print('Freedom')
else:
print('Human Rights')

11 changes: 11 additions & 0 deletions lwh/11/filtered_words.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
����
����Ա
����Ա
�쵼
ţ��
ţ��
����
����
love
sex
jiangge
12 changes: 6 additions & 6 deletions lwh/7/line_counter.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,24 +32,24 @@ def isnote(line):

for filename in filenames:
os.chdir(parent)
print(filename)
print(parent)
# print(filename)
# print(parent)
with open(filename, "rb") as f:
line = f.readline().strip()
while line != b"":
print("*")
# print("*")
ret = isnote(line)
print(ret)
# print(ret)
if ret == "//":
note_count = note_count + 1
elif ret == "/*":
line = f.readline().strip()
print(line)
# print(line)
# if len(line) >= 2:
while b"*/" in line:
note_count = note_count + 1
line = f.readline().strip()
print(line)
# print(line)
elif ret == "no":
code_count = code_count + 1
line = f.readline().strip()
Expand Down