
Python
Geek_ymv
公众号 geekymv
展开
-
从51job提取职位数量
import urllib.request import re url = "https://search.51job.com/list/150200,000000,0000,00,9,99,java,2,1.html?lang=c&stype=&postchannel=0000&workyear=99&cotype=99°reefrom=99&am...原创 2020-03-28 13:06:05 · 514 阅读 · 0 评论 -
py练习一:登录接口
需求: 编写登录接口 1.输入用户名密码 2.认证成功后显示欢迎信息 3.输错三次后锁定 # 连续登录错误次数 count = 3 f = open('userinfo.txt', 'r') user_infos = {} for info in f.readlines(): i = info.split(':') if i[0] != '\n': user_infos[i[0]] =原创 2016-03-14 22:33:15 · 980 阅读 · 0 评论 -
py解析xml
https://github.com/geekymv/py-demo/blob/master/20160224-xml/parseXml.py原创 2016-03-07 20:09:00 · 753 阅读 · 0 评论 -
使用Python对新农网爬取小麦种植技术文章
参考博文:Python爬虫实战一之爬取糗事百科段子 爬取的文章列表 代码: # -*- coding: utf-8 -*- import urllib2 import string import re # 发送请求,得到返回的结果html def getHtml(url): try: req = urllib2.Request(url) ...原创 2015-04-15 13:30:13 · 1588 阅读 · 0 评论 -
Python面向对象
# -*- coding: utf-8 -*- class Employee: '所有员工的基类' __secretCount = 0; # 私有变量 empCount = 0 # 类变量 def __init__(self, name, salary): print '执行了__init__方法' self.name = na原创 2015-04-15 16:30:07 · 875 阅读 · 0 评论 -
使用Python urllib2下载CSDN博客列表到本地
# -*- coding: utf-8 -*- import string, urllib2 # 下载CSDN博客列表 def load_csdn(url, page): name = string.zfill(page, 5) + '.html' print '正在下载' + str(page) + '个页面,并存储其为' + name f = open(name,原创 2015-04-14 13:36:58 · 912 阅读 · 0 评论 -
Django数据库操作
1.安装MySQL-python 根据自己的系统,选择合适的版本.下载地址:http://www.codegood.com/archives/129 2.在settings.py文件中配置数据库原创 2014-11-18 20:36:33 · 695 阅读 · 0 评论 -
Django1.6学习--为博客添加comments(评论)功能
Django1.6 不再自带comments这个app了,见官方解释 https://docs.djangoproject.com/en/1.6/ref/contrib/comments/example/#example-of-using-the-built-in-comments-app 虽然不再自带,但是仍然可以自己安装实现,根据官方文档 在github上 https://gith原创 2014-11-29 19:57:36 · 4837 阅读 · 0 评论 -
Django模板的使用
方式一: # coding: utf-8 from django.http import HttpResponse from django.template import loader, Context def login(request): t = loader.get_template('login.html') c = Context({}) retu原创 2014-11-18 19:22:57 · 784 阅读 · 0 评论 -
在Windows下安装Django
在Windows下安装Django 1.安装Python 2.配置环境变量: D:\Python27 D:\Python27\Scripts 3.安装Django :进入Django安装包所在目录,执行python setup.py install 在IDLE中运行>>> import django >>> print django.get_versi原创 2014-10-06 20:51:56 · 750 阅读 · 0 评论