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中DataFrame按照行遍历的方法

在做分类模型时候,需要在DataFrame中按照行获取数据以便于进行训练和测试。 import pandas as pd dict=[[1,2,3,4,5,6],[2,3,4,5,6...

Tensorflow中使用tfrecord方式读取数据的方法

Tensorflow中使用tfrecord方式读取数据的方法

前言 本博客默认读者对神经网络与Tensorflow有一定了解,对其中的一些术语不再做具体解释。并且本博客主要以图片数据为例进行介绍,如有错误,敬请斧正。 使用Tensorflow训练神...

python切片及sys.argv[]用法详解

一、python切片 a=a[::-1] 倒序 a=a[1:10:2] 下标1~10,以2间隔取 a=a[::2] 2间隔返回a[:] a=[1,2,3,4,5,6,7] print...

Python中常见的异常总结

一、异常错误    a、语法错误 错误一: if 错误二: def  text:       pass...

python使用百度文字识别功能方法详解

python使用百度文字识别功能方法详解

介绍python使用百度智能去的文字识别功能,可以识别截图中的文,登陆路验证码等等。, 登陆百度智能云,选择产品服务。 选择“人工智能”---文字识别。 点击创建应用。 如图下面有关...