摘要: urlopen方法返回一个html 对html使用info()方法返回HTTPMessage对象实例 阅读全文
posted @ 2018-06-06 22:06 了解2号 阅读(102) 评论(0) 推荐(0) 编辑
摘要: urllib.urlopen()方法: 参数: 1.url(要访问的网页链接http:或者是本地文件file:) 2.data(如果有,就会由GET方法变为POST方法,提交的数据格式必须是application/x-www-form-urlencoded格式) 返回值: 返回类文件句柄 常用方法 阅读全文
posted @ 2018-06-06 21:54 了解2号 阅读(156) 评论(0) 推荐(0) 编辑
摘要: # -*- coding: UTF-8 -*- import smtplib from email.mime.text import MIMEText import email.mime.multipart # 第三方 SMTP 服务 mail_host="smtp.163.com" #设置服务器 mail_user="xxxxx" #用户名 mail_pass="xxx" #口... 阅读全文
posted @ 2018-06-06 14:46 了解2号 阅读(882) 评论(0) 推荐(0) 编辑
摘要: # -*- coding: UTF-8 -*- import smtplib from email.mime.text import MIMEText from email.header import Header # 第三方 SMTP 服务 mail_host="smtp.qq.com" #设置服务器 mail_user="QQ号@qq.com" #用户名 mail_pass=... 阅读全文
posted @ 2018-06-06 13:09 了解2号 阅读(151) 评论(0) 推荐(0) 编辑
摘要: 功能:将字符串str当成有效的表达式来求值并返回计算结果。 语法: eval(source[, globals[, locals]]) -> value 参数: source:一个Python表达式或函数compile()返回的代码对象 globals:可选。必须是dictionary locals 阅读全文
posted @ 2018-06-05 15:30 了解2号 阅读(1543) 评论(0) 推荐(0) 编辑
摘要: map()方法 map(func, *iterables) --> map object lambda方法: lambda 参数 :返回值 运行结果:['12', '34', 11] 阅读全文
posted @ 2018-06-05 11:37 了解2号 阅读(293) 评论(0) 推荐(0) 编辑
摘要: 注意字符串join方法的使用 对于数字列表上面方法要改进,否则会报错 改进使用map()函数 map()函数:有2个参数,第一个参数是方法(自定义方法,lambda),第二个参数是可迭代对象 输出结果:'12345' 阅读全文
posted @ 2018-06-02 13:17 了解2号 阅读(2317) 评论(0) 推荐(0) 编辑
摘要: # -*- coding: cp936 -*- import requests from lxml import etree url = 'https://weibo.cn/pub/' html = requests.get(url).content #先用.content再用etree.HTML(html)方法,不然报错 selector = etree.HTML(html) ''' #... 阅读全文
posted @ 2018-05-25 21:05 了解2号 阅读(430) 评论(0) 推荐(0) 编辑
摘要: content是bytes数据,包括图片等二进制数据;text是网页代码 content在python 2.7版本中可以顺利打印出网页代码;但是在Python3.6上面打印的中文是乱码,而且很卡,代码持续行状态 text在python 2.7版本中打印出网页代码中文乱码;在Python3.6上面打印 阅读全文
posted @ 2018-05-25 15:00 了解2号 阅读(244) 评论(0) 推荐(0) 编辑
摘要: \d+使用匹配数字 阅读全文
posted @ 2018-05-22 19:32 了解2号 阅读(35278) 评论(0) 推荐(0) 编辑