本文实例讲述了Python实现向QQ群成员自动发邮件的方法。分享给大家供大家参考。具体实现方法如下:
原理:
我们需要先获取QQ群中的所有成员并保存到一个txt文本中去,然后再由python读取文件然后进行批量邮件发送了,具体解决方案如下:
1. 获取QQ群成员QQ号码,QQ群成员信息可以在如下网页中获取,选择全部成员保存在txt中即可
http://qun.qzone.qq.com/group#!/123456/member
(这里的123456为QQ群号码)
2. 解析获取的QQ群成员列表list.txt,给每个成员单独自动发送邮件,这里使用的发送方是163邮箱
完整脚本如下:
代码如下:
#coding:utf-8
import random
import smtplib
from email.mime.text import MIMEText
import time
def send_mail(mailto):
print 'Setting MIMEText'
CT=open('content.txt','r') #读取发送邮件内容
content=CT.read().decode('utf-8')
msg=MIMEText(content.encode('utf8'),_subtype='html')
CT.close()#关闭文件
msg['From']=mail_user
msg['SUbject']=u'Python邮件发送测试'
msg['To']=mailto
try:
print 'Connectting',mail_host
s=smtplib.SMTP_SSL(mail_host,465)
print 'Login to mail_host'
s.login(mail_user,mail_pwd)
print 'Send mail'
s.sendmail(mail_user,mailto,msg.as_string())
print 'Close the connection between the mail server'
s.close()
except Exception as e:
print "Exceptioin ",e
def sendqunmail():
try:
f=open(filelist,'r')
lines=f.readlines()
for i in range(len(lines)-1):
if lines[i].find('(')-1 and lines[i].find(')')-1:
qqnum=lines[i].split('(')[1].split(')')[0]
if qqnum.isdigit():
mailto=qqnum+'@qq.com'
print 'Sendmail to:'+mailto
send_mail(mailto)
time.sleep(10)
except Exception,ex:
print filelist,ex
if __name__=="__main__":
mail_host='smtp.163.com'
mail_user='test@163.com'
mail_pwd='test123'
filelist='list.txt'
sendqunmail()
希望本文所述对大家的Python程序设计有所帮助。

Pythonarrayssupportvariousoperations:1)Slicingextractssubsets,2)Appending/Extendingaddselements,3)Insertingplaceselementsatspecificpositions,4)Removingdeleteselements,5)Sorting/Reversingchangesorder,and6)Listcomprehensionscreatenewlistsbasedonexistin

NumPyarraysareessentialforapplicationsrequiringefficientnumericalcomputationsanddatamanipulation.Theyarecrucialindatascience,machinelearning,physics,engineering,andfinanceduetotheirabilitytohandlelarge-scaledataefficiently.Forexample,infinancialanaly

useanArray.ArarayoveralistinpythonwhendeAlingwithHomoGeneData,performance-Caliticalcode,orinterfacingwithccode.1)同質性data:arraysSaveMemorywithTypedElements.2)績效code-performance-calitialcode-calliginal-clitical-clitical-calligation-Critical-Code:Arraysofferferbetterperbetterperperformanceformanceformancefornallancefornalumericalical.3)

不,notalllistoperationsareSupportedByArrays,andviceversa.1)arraysdonotsupportdynamicoperationslikeappendorinsertwithoutresizing,wheremactsperformance.2)listssdonotguaranteeconecontanttanttanttanttanttanttanttanttanttimecomplecomecomplecomecomecomecomecomecomplecomectacccesslectaccesslecrectaccesslerikearraysodo。

toAccesselementsInapythonlist,useIndIndexing,負索引,切片,口頭化。 1)indexingStartSat0.2)否定indexingAccessesessessessesfomtheend.3)slicingextractsportions.4)iterationerationUsistorationUsisturessoreTionsforloopsoreNumeratorseforeporloopsorenumerate.alwaysCheckListListListListlentePtotoVoidToavoIndexIndexIndexIndexIndexIndExerror。

Arraysinpython,尤其是Vianumpy,ArecrucialInsCientificComputingfortheireftheireffertheireffertheirefferthe.1)Heasuedfornumerericalicerationalation,dataAnalysis和Machinelearning.2)Numpy'Simpy'Simpy'simplementIncressionSressirestrionsfasteroperoperoperationspasterationspasterationspasterationspasterationspasterationsthanpythonlists.3)inthanypythonlists.3)andAreseNableAblequick

你可以通過使用pyenv、venv和Anaconda來管理不同的Python版本。 1)使用pyenv管理多個Python版本:安裝pyenv,設置全局和本地版本。 2)使用venv創建虛擬環境以隔離項目依賴。 3)使用Anaconda管理數據科學項目中的Python版本。 4)保留系統Python用於系統級任務。通過這些工具和策略,你可以有效地管理不同版本的Python,確保項目順利運行。

numpyarrayshaveseveraladagesoverandastardandpythonarrays:1)基於基於duetoc的iMplation,2)2)他們的aremoremoremorymorymoremorymoremorymoremorymoremoremory,尤其是WithlargedAtasets和3)效率化,效率化,矢量化函數函數函數函數構成和穩定性構成和穩定性的操作,製造


熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

Video Face Swap
使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

熱工具

EditPlus 中文破解版
體積小,語法高亮,不支援程式碼提示功能

Atom編輯器mac版下載
最受歡迎的的開源編輯器

MinGW - Minimalist GNU for Windows
這個專案正在遷移到osdn.net/projects/mingw的過程中,你可以繼續在那裡關注我們。 MinGW:GNU編譯器集合(GCC)的本機Windows移植版本,可自由分發的導入函式庫和用於建置本機Windows應用程式的頭檔;包括對MSVC執行時間的擴展,以支援C99功能。 MinGW的所有軟體都可以在64位元Windows平台上運作。

Dreamweaver CS6
視覺化網頁開發工具

SecLists
SecLists是最終安全測試人員的伙伴。它是一個包含各種類型清單的集合,這些清單在安全評估過程中經常使用,而且都在一個地方。 SecLists透過方便地提供安全測試人員可能需要的所有列表,幫助提高安全測試的效率和生產力。清單類型包括使用者名稱、密碼、URL、模糊測試有效載荷、敏感資料模式、Web shell等等。測試人員只需將此儲存庫拉到新的測試機上,他就可以存取所需的每種類型的清單。