Python httplib,smtplib使用方法

yipeiwu_com6年前Python基础

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

import httplib

conn=httplib.HTTPConnection("www.tingtuge.com")
conn.request("GET", "/?id=35")
r=conn.getresponse()
print r.read() #获取所有内容

例二:使用smtplib发送邮件

import smtplib
smtpServer = 'smtp.xxx.com'
fromaddr = 'foo@xxx.com'
toaddrs = 'your@xxx.com'
msg = 'Subject: xxxxxxxxx'
server = smtplib.SMTP(smtpServer)
server.sendmail(fromaddr, toaddrs, msg)
server.quit( )


标签: zip打包

相关文章

分析python切片原理和方法

分析python切片原理和方法

使用索引获取列表的元素(随机读取) 列表元素支持用索引访问,正向索引从0开始 colors=["red","blue","green"] colors[0] =="red"...

python 多线程串行和并行的实例

如下所示: #coding=utf-8 import threading import time import cx_Oracle from pprint import pprint...

Python判断一个list中是否包含另一个list全部元素的方法分析

本文实例讲述了Python判断一个list中是否包含另一个list全部元素的方法。分享给大家供大家参考,具体如下: 你可以用for in循环+in来判断 #!/usr/bin/env...

python selenium UI自动化解决验证码的4种方法

本文介绍了python selenium UI自动化解决验证码的4种方法,分享给大家,具体如下: 测试环境 windows7+ firefox50+ geckodrive...

python中找出numpy array数组的最值及其索引方法

在list列表中,max(list)可以得到list的最大值,list.index(max(list))可以得到最大值对应的索引 但在numpy中的array没有index方法,取而代之...