【学习笔记】python-配置文件和发送邮件

一、配置文件(标签、数据项)
配置文件db.conf
[DATEBASE]
config={
'host':'xxx',
'user':'xxx',
'password':'xxx',
'port':3306,
'database':'test',
}

成都创新互联公司科技有限公司专业互联网基础服务商,为您提供服务器托管高防服务器租用,成都IDC机房托管,成都主机托管等互联网服务。

读取配置文件
import configparser
cf=configparser.ConfigParser()
cf.read('db.conf')
config=cf.get('DATEBASE','config')
print config

二、发送邮件
1、组装内容 email.mime.text
2、发送邮件 smtplib
from email.mime.text import MIMEText
import smtplib

msg_from='xxx@qq.com'
passwd='xxx'
msg_to='xxx@qq.com'

subject='zhuti'
content='666'

msg=MIMEText(content)
msg['Subject']=subject
msg['From']=msg_from
msg['To']=msg_to

s=smtplib.SMTP_SSL("smtp.qq.com",465)
s.login(msg_from,passwd)
s.sendmail(msg_from,msg_from,msg.as_string())
s.quit()


分享标题:【学习笔记】python-配置文件和发送邮件
分享路径:http://csruizhi.cn/article/joiosg.html

其他资讯

Copyright © 2007-2024 成都优众联杰科技有限公司 All Rights Reserved 蜀ICP备2024116266号
友情链接: 手机网站建设 成都网站设计 成都网站设计制作公司 成都网站建设 专业网站设计 宜宾网站设计 成都网站建设公司 外贸网站设计方案 成都网站建设 网站制作 手机网站制作设计 成都网站设计 成都商城网站建设 重庆外贸网站建设 手机网站制作 定制网站制作 成都网站设计 高端网站设计 成都模版网站建设 H5网站制作 定制网站设计 网站建设公司