一、配置文件(標簽、數(shù)據(jù)項)
配置文件db.conf
[DATEBASE]
config={
'host':'xxx',
'user':'xxx',
'password':'xxx',
'port':3306,
'database':'test',
}
成都創(chuàng)新互聯(lián)公司科技有限公司專業(yè)互聯(lián)網(wǎng)基礎(chǔ)服務商,為您提供服務器托管,高防服務器租用,成都IDC機房托管,成都主機托管等互聯(lián)網(wǎng)服務。
讀取配置文件
import configparser
cf=configparser.ConfigParser()
cf.read('db.conf')
config=cf.get('DATEBASE','config')
print config
二、發(fā)送郵件
1、組裝內(nèi)容 email.mime.text
2、發(fā)送郵件 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-配置文件和發(fā)送郵件
網(wǎng)站地址:http://www.chinadenli.net/article36/joiosg.html
成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供品牌網(wǎng)站制作、做網(wǎng)站、小程序開發(fā)、App設計、網(wǎng)站設計公司、域名注冊
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)