1、配置文件(標籤、數據項)
配置文件db.conf
[DATEBASE]
config={
'host':'xxx',
'user':'xxx',
'password':'xxx',
'port':3306,
'database':'test',
}ide
讀取配置文件
import configparser
cf=configparser.ConfigParser()
cf.read('db.conf')
config=cf.get('DATEBASE','config')
print configui
2、發送郵件
一、組裝內容 email.mime.text
二、發送郵件 smtplib
from email.mime.text import MIMEText
import smtplibget
msg_from='xxx@qq.com'
passwd='xxx'
msg_to='xxx@qq.com'string
subject='zhuti'
content='666'it
msg=MIMEText(content)
msg['Subject']=subject
msg['From']=msg_from
msg['To']=msg_toclass
s=smtplib.SMTP_SSL("smtp.qq.com",465)
s.login(msg_from,passwd)
s.sendmail(msg_from,msg_from,msg.as_string())
s.quit()test