Skip to content

Commit 3ea1672

Browse files
committed
tomorrow is a beautiful day.i swear.
1 parent b112826 commit 3ea1672

1 file changed

Lines changed: 63 additions & 17 deletions

File tree

re.py

Lines changed: 63 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,63 @@
1-
from email.mime.text import MIMEText
2-
3-
4-
# 输入Email地址和口令:
5-
from_addr = raw_input('From: ')
6-
password = raw_input('Password: ')
7-
# 输入SMTP服务器地址:
8-
smtp_server = raw_input('SMTP server: ')
9-
# 输入收件人地址:
10-
to_addr = raw_input('To: ')
11-
12-
import smtplib
13-
server = smtplib.SMTP(smtp_server, 25) # SMTP协议默认端口是25
14-
server.set_debuglevel(1)
15-
server.login(from_addr, password)
16-
server.sendmail(from_addr, [to_addr], msg.as_string())
17-
server.quit()
1+
__author__ = '绍文'
2+
3+
4+
import Image, ImageDraw, ImageFont, ImageFilter
5+
import random
6+
7+
# 随机字母:
8+
def rndChar():
9+
return chr(random.randint(65, 90))
10+
11+
# 随机颜色1:
12+
def rndColor():
13+
return (random.randint(64, 255), random.randint(64, 255), random.randint(64, 255))
14+
15+
# 随机颜色2:
16+
def rndColor2():
17+
return (random.randint(32, 127), random.randint(32, 127), random.randint(32, 127))
18+
19+
# 240 x 60:
20+
width = 60 * 4
21+
height = 60
22+
image = Image.new('RGB', (width, height), (255, 255, 255))
23+
# 创建Font对象:
24+
font = ImageFont.truetype('Arial.ttf', 36)
25+
# 创建Draw对象:
26+
draw = ImageDraw.Draw(image)
27+
# 填充每个像素:
28+
for x in range(width):
29+
for y in range(height):
30+
draw.point((x, y), fill=rndColor())
31+
# 输出文字:
32+
for t in range(4):
33+
draw.text((60 * t + 10, 10), rndChar(), font=font, fill=rndColor2())
34+
# 模糊:
35+
image = image.filter(ImageFilter.BLUR)
36+
image.save('code.jpg', 'jpeg');
37+
38+
from urllib2 import Request, urlopen, URLError, HTTPError
39+
40+
req = Request('http://bbs.csdn.net/callmewhy')
41+
42+
try:
43+
44+
response = urlopen(req)
45+
46+
except URLError, e:
47+
48+
if hasattr(e, 'code'):
49+
50+
print 'The server couldn\'t fulfill the request.'
51+
52+
print 'Error code: ', e.code
53+
54+
elif hasattr(e, 'reason'):
55+
56+
print 'We failed to reach a server.'
57+
58+
print 'Reason: ', e.reason
59+
60+
61+
else:
62+
print 'No exception was raised.'
63+
# everything is fine

0 commit comments

Comments
 (0)