
【Python】
liuyu2783
Java开发工程师
展开
-
Python3.5爬虫入门示例-获取百度首页及相关的html页面
# crawl.py# 网络爬虫from os import makedirs, unlink, sepfrom os.path import dirname, exists, isdir, splitextimport urllib.requestfrom urllib.parse import urlparsefrom sys import argvimport html.pa原创 2016-04-12 10:42:07 · 2181 阅读 · 0 评论 -
Python2.7实现监控Linux内存、CPU并发送预警邮件
Python2.7实现监控Linux内存、CPU并发送预警邮件。参考点:psutil库监控服务器指标smtplib库发送中文html邮件linux守护进程原创 2017-11-22 10:27:23 · 2231 阅读 · 0 评论 -
Python 半自动登录知乎-验证码需要识别
import timefrom bs4 import BeautifulSoupimport requests__file__ = 'zhihudata.py'__author__ = 'Jerry Liu'__date__ = '2016-04-21'headers_base = { 'Accept': 'text/html,application/xhtml+xml,applic原创 2016-04-21 16:29:53 · 1792 阅读 · 0 评论 -
Python 完成2048
python3.5 2048原创 2016-04-19 17:19:50 · 1104 阅读 · 0 评论 -
phyton3.5 django典型错误
1、使用命令安装pymsql>pip install -U --force-reinstall PyMySQL2、在工程的__init__.py文件中增加一下2行代码import pymysqlpymysql.install_as_MySQLdb()原创 2016-04-18 14:44:32 · 384 阅读 · 0 评论 -
Show me the code之Python练习册 Q17~19 xml操作
__file__ = 'A17.py'__author__ = 'Jerry Liu'__date__ = '2016-04-15'""" 问题: 第 0014 题中的 student.xls 文件中的内容写到 student.xml 文件中,如下所示: <?xml version="1.0" encoding="UTF-8"?> <root>原创 2016-04-18 09:26:49 · 704 阅读 · 0 评论 -
Show me the code之Python练习册 Q14~16 excel操作
""" 问题:纯文本文件 student.txt为学生信息, 里面的内容(包括花括号)如下所示: { "1":["张三",150,120,100], "2":["李四",90,99,95], "3":["王五",60,66,68] } 请将上述内容写到 student.xl原创 2016-04-14 16:02:12 · 458 阅读 · 0 评论 -
Show me the code之Python练习册 Q13 获取网络图片
""" 问题:用 Python 写一个爬图片的程序 常用库:BeautifulSoup"""from bs4 import BeautifulSoupimport urllib.requestfrom os.path import dirname, existsfrom os import makedirs# 获取图片的url连接def getImg(url):原创 2016-04-14 11:06:27 · 723 阅读 · 0 评论 -
Show me the code之Python练习册 Q11~12 关键词过滤
""" 问题:敏感词文本文件 filtered_words.txt,里面的内容为以下内容,当用户输入敏感词语时,则打印出 Freedom,否则打印出 Human Rights。"""def filterwords(): words = [] f = open('d://filtered_words.txt', 'rb') for l in f.readlines()原创 2016-04-14 11:05:22 · 1160 阅读 · 0 评论 -
Show me the code之Python练习册 Q10 生成验证码
""" 问题:使用 Python 生成类似于下图中的字母验证码图片"""from PIL import Image, ImageFont, ImageDrawimport random# 图片宽度width = 100# 图片高度height = 40def getcodeimg(): choiceCode = ['1', '2', '3', '4', '5', '6'原创 2016-04-14 11:03:43 · 617 阅读 · 0 评论 -
Show me the code之Python练习册 Q1~3 优惠券
""" 问题:将你的 QQ 头像(或者微博头像)右上角加上红色的数字,类似于微信未读信息数量那种提示效果 常用库:图像处理的库:PIL 安装pillow库: 1、http://www.lfd.uci.edu/~gohlke/pythonlibs/下载 Pillow-3.2.0-cp35-cp35m-win_amd64.whl 2、使用命原创 2016-04-14 09:08:45 · 1033 阅读 · 0 评论 -
Show me the code之Python练习册 Q4~7
""" 问题:任一个英文的纯文本文件,统计其中的单词出现的个数。"""import redef count(path): f = open(path, 'r') s = f.read() wcount = re.findall('[\S\w+\b]+', s) print(len(wcount))if __name__ == '__main__':原创 2016-04-14 09:12:36 · 624 阅读 · 0 评论 -
Show me the code之Python练习册 Q8~9 html解析
""" 问题:一个HTML文件,找出里面的 正文 常用库:BeautifulSoup 安装pillow库: 1、http://www.lfd.uci.edu/~gohlke/pythonlibs/下载 BeautifulSoup-3.2.1-py2-none-any.whl 2、使用命令pip install BeautifulSoup-3.2.1-py2-n原创 2016-04-14 09:14:10 · 681 阅读 · 0 评论 -
python爬虫-爬取找建筑网站术语
#!/usr/bin/env python# coding=utf-8# 爬取找建筑 术语import urllib2from bs4 import BeautifulSoupimport xlwtheaders = {'User-Agent': 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.6) Gecko/2原创 2018-01-31 13:33:46 · 903 阅读 · 0 评论