例一:使用httplib访问某个url然后获取返回的内容:

Python天天美味(21) - httplib,smtplibimport httplib
Python天天美味(21) - httplib,smtplib
Python天天美味(21) - httplib,smtplibconn
=httplib.HTTPConnection("www.cnblogs.com")
Python天天美味(21) - httplib,smtplibconn.request(
"GET""/coderzh/archive/2008/05/13/1194445.html")
Python天天美味(21) - httplib,smtplibr
=conn.getresponse()
Python天天美味(21) - httplib,smtplib
print r.read() #获取所有内容

例二:使用smtplib发送邮件

Python天天美味(21) - httplib,smtplibimport smtplib
Python天天美味(21) - httplib,smtplibsmtpServer 
= 'smtp.xxx.com'
Python天天美味(21) - httplib,smtplibfromaddr 
= 'foo@xxx.com'
Python天天美味(21) - httplib,smtplibtoaddrs 
= 'your@xxx.com'
Python天天美味(21) - httplib,smtplibmsg 
= 'Subject: xxxxxxxxx'
Python天天美味(21) - httplib,smtplibserver 
= smtplib.SMTP(smtpServer)
Python天天美味(21) - httplib,smtplibserver.sendmail(fromaddr, toaddrs, msg)
Python天天美味(21) - httplib,smtplibserver.quit( )


Python 天天美味系列(总)

Python 天天美味(19) - 时间处理datetime  

Python 天天美味(20) - 命令行参数sys.argv   

Python 天天美味(21) - httplib,smtplib  

Python 天天美味(22) - 拷贝对象(深拷贝deepcopy与浅拷贝copy)  

Python 天天美味(23) - enumerate遍历数组

...

相关文章:

  • 2021-06-13
  • 2021-10-07
  • 2022-01-28
  • 2021-05-28
  • 2021-12-13
  • 2021-06-25
  • 2021-12-15
猜你喜欢
  • 2021-08-11
  • 2021-10-11
  • 2021-08-17
  • 2021-08-15
  • 2022-01-15
  • 2021-08-03
相关资源
相似解决方案