Skip to content

Commit 35ebcbb

Browse files
committed
2 parents 6418829 + 7da6ea8 commit 35ebcbb

File tree

22 files changed

+458
-11
lines changed

22 files changed

+458
-11
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
Python技术 公众号文章代码库
44

55

6-
关注公众号:python 技术,回复"python"一起学习交流
6+
关注公众号:python技术,回复"python"一起学习交流
77

88
![](http://favorites.ren/assets/images/python.jpg)

chaoxi/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
+ [feiyan_data](https://github.com/JustDoPython/python-examples/tree/master/chaoxi/2020-02-24-feiyan_data) :肺炎数据抓取并展示
44
+ [cherry_tree](https://github.com/JustDoPython/python-examples/tree/master/chaoxi/2020-03-24-cherry_tree) :Python 樱花小技
55
+ [jupyter_notebook](https://github.com/JustDoPython/python-examples/tree/master/chaoxi/2020-03-30-jupyter_notebook) :Python Jupyter notebook 操作
6+
+ [send_email](https://github.com/JustDoPython/python-examples/tree/master/chaoxi/2020-04-07-send_email) :今天,我用 Python 给武汉人民发一封邮件
67

78
---
89

chaoxi/2020-03-24-cherry_tree/cherry_tree.py renamed to chaoxi/flower/flower_tree.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
def cherryTree(branch, t):
55
if branch > 4:
6+
# 枝干数
67
if 7 <= branch <= 13:
78
# 随机数生成
89
if random.randint(0, 3) == 0:
@@ -15,8 +16,8 @@ def cherryTree(branch, t):
1516
if random.randint(0, 2) == 0:
1617
t.color('snow')
1718
else:
18-
# 设置樱花树叶颜色
19-
t.color('green') # 樱花树颜色
19+
# 设置树叶颜色
20+
t.color('green')
2021
t.pensize(branch / 5)
2122
else:
2223
t.color('Peru') # 树干颜色
@@ -63,18 +64,18 @@ def petal(m, t):
6364
def des_word():
6465
t.color('LightCoral') # 字体颜色设置
6566
t.hideturtle()
66-
t.goto(-50,-130)
67+
# t.goto(-50, -130)
68+
t.goto(-60,-170)
6769
t.pu()
68-
# 昨日雪如花,今日花如雪,山樱如美人,红颜易消歇。
69-
t.write('昨日雪如花,',move=False, align='center', font=('Arial', 20, 'normal'))
70+
t.write('姹紫嫣红桃花笺,',move=False, align='center', font=('Arial', 20, 'normal'))
7071
t.pd()
7172

7273
t.pu()
73-
t.goto(90,-130)
74-
t.write('今日花如雪', move=False, align='center', font=('Arial', 20, 'normal'))
74+
# t.goto(90, 130)
75+
t.goto(150,-170)
76+
t.write('繁花似锦为君妍', move=False, align='center', font=('Arial', 20, 'normal'))
7577
t.pd()
7678

77-
7879
# 绘图区域
7980
t = turtle.Turtle()
8081
# 画布大小 获取到屏幕

chaoxi/send_email/email2friend.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import smtplib
2+
from email.mime.text import *
3+
from email.utils import formataddr
4+
5+
my_sender = '[email protected]' # 发送方邮箱
6+
my_psw = 'xxxxxxxxxxx' # 填入发送方邮箱的授权码
7+
my_user = '[email protected]' # 收件人邮箱
8+
9+
10+
def send_email():
11+
ret = True
12+
try:
13+
msg = MIMEText('待花开时,邀您一起赏花吃热干面,我们重新拥抱这座城市的热情', 'plain', 'utf-8')
14+
15+
msg['From'] = formataddr(["知心。。。。", my_sender]) # 发件人邮箱昵称、发件人邮箱账号
16+
msg['To'] = formataddr(["知心。。。。", my_user]) # 收件人邮箱昵称、收件人邮箱账号
17+
msg['Subject'] = "静待归期!" # 邮件主题
18+
19+
server = smtplib.SMTP_SSL("smtp.qq.com", 465) # 发件人邮箱中的SMTP服务器,端口是25
20+
21+
server.login(my_sender, my_psw) # 发件人邮箱账号、邮箱密码
22+
server.sendmail(my_sender, [my_user, ], msg.as_string()) # 发件人邮箱账号、授权码、收件人邮箱账号、发送邮件
23+
server.quit() # 关闭连接
24+
except Exception: # 如果 try 中的语句没有执行,则会执行下面的 ret=False
25+
ret = False
26+
return ret
27+
28+
ret = send_email()
29+
if ret:
30+
print(ret)
31+
print("邮件发送成功")
32+
else:
33+
print(ret)
34+
print("邮件发送失败")
35+

chaoxi/send_email/email2wuhan.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import smtplib
2+
from email.mime.text import MIMEText
3+
from email.mime.multipart import MIMEMultipart
4+
from email.header import Header
5+
6+
7+
my_sender = '[email protected]' # 发送方邮箱
8+
my_psw = 'xxxxxxxxxxx' # 填入发送方邮箱的授权码
9+
my_user = '[email protected]' # 收件人邮箱
10+
11+
12+
# 创建一个带附件的实例
13+
message = MIMEMultipart()
14+
message['From'] = Header("潮汐同学", 'utf-8')
15+
message['To'] = Header("武汉人民", 'utf-8')
16+
subject = '荆楚疫情去'
17+
message['Subject'] = Header(subject, 'utf-8')
18+
19+
# 邮件正文内容
20+
message.attach(MIMEText('南山镇守江南之都,且九州一心!月余,疫尽去,举国庆之!', 'plain', 'utf-8'))
21+
# 构造附件1,传送当前目录下的 test.txt 文件
22+
att1 = MIMEText(open('./test.txt', 'rb').read(), 'base64', 'utf-8')
23+
att1["Content-Type"] = 'application/octet-stream'
24+
# 这里的filename可以任意写,写什么名字,邮件中显示什么名字
25+
att1["Content-Disposition"] = 'attachment; filename="test.txt"'
26+
message.attach(att1)
27+
28+
try:
29+
server = smtplib.SMTP_SSL("smtp.qq.com", 465) # 发件人邮箱中的SMTP服务器,端口是25
30+
31+
server.login(my_sender, my_psw) # 发件人邮箱账号、邮箱密码
32+
server.sendmail(my_sender, my_user, message.as_string())
33+
server.quit() # 关闭连接
34+
print("邮件发送成功")
35+
except smtplib.SMTPException:
36+
print("Error: 无法发送邮件")
37+

chaoxi/send_email/picture.png

1.33 MB
Loading

chaoxi/send_email/sendemail2wh.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import smtplib
2+
from email.mime.text import MIMEText
3+
from email.header import Header
4+
from email.mime.multipart import MIMEMultipart
5+
from email.mime.text import MIMEText
6+
from email.mime.image import MIMEImage
7+
8+
my_sender = '[email protected]' # 发送方邮箱
9+
my_psw = 'xxxxxxxxxxx' # 填入发送方邮箱的授权码
10+
my_user = '[email protected]' # 收件人邮箱
11+
12+
13+
def send():
14+
subject = "解封纪念日" # 主题
15+
msg = MIMEMultipart('related')
16+
content = MIMEText('<html><body><img src="cid:imageid" alt="imageid"></body></html>', 'html', 'utf-8') # 正文
17+
# msg = MIMEText(content)
18+
msg.attach(content)
19+
msg['From'] = Header("潮汐同学", 'utf-8')
20+
msg['To'] = Header("武汉人民", 'utf-8')
21+
msg['Subject'] = Header(subject, 'utf-8')
22+
23+
file = open("./picture.png", "rb")
24+
img_data = file.read()
25+
file.close()
26+
27+
img = MIMEImage(img_data)
28+
img.add_header('Content-ID', 'imageid')
29+
msg.attach(img)
30+
31+
try:
32+
s = smtplib.SMTP_SSL("smtp.qq.com", 465) # 邮件服务器及端口号
33+
s.login(my_sender, my_psw)
34+
s.sendmail(my_sender, my_user, msg.as_string())
35+
print("邮件发送成功")
36+
except smtplib.SMTPException:
37+
print("Error: 无法发送邮件")
38+
39+
if __name__ == '__main__':
40+
send()

0 commit comments

Comments
 (0)