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中的if、else、elif语句用法简明讲解

下面我们学习if语句,输入下面的代码,确保能够正确运行。 people = 20 cats = 30 dogs = 15 if people < cats:...

python实现图片中文字分割效果

python实现图片中文字分割效果

本文实例为大家分享了python实现图片中文字分割的具体代码,供大家参考,具体内容如下 1、原始图片(包含数字): 结果图: 2、原始图片(包含文字): 结果图: 3、代码如下:...

python Tkinter版学生管理系统

python Tkinter版学生管理系统

本文实例为大家分享了python Tkinter版学生管理的具体代码,供大家参考,具体内容如下 Tkinter是python自带的UI包,无需下载,只需要导入 tkinter 文档 //...

Python实现的一个自动售饮料程序代码分享

写这个程序的时候,我已学习Python将近有一百个小时,在CSDN上看到有人求助使用Python如何写一个自动售饮料的程序,我一想,试试写一个实用的售货程序。当然,只是实现基本功能,欢迎...

python实现将一个数组逆序输出的方法

方法一: def printTheReverseArray(self): list_1 = [1, 2, 3, 4, 5, 6, 7] length = len(list_1...