自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(37)
  • 资源 (4)
  • 收藏
  • 关注

原创 python 学习笔记(二十九)

# coding=utf8__author__ = 'liwei'from flask import Flaskfrom flask import requestapp = Flask(__name__)@app.route('/', methods=['GET', 'POST'])def home(): return 'Home'@app.route('/signin

2015-01-06 10:44:04 266

原创 python 学习笔记(二十八)

WSGI的处理函数# coding=utf8__author__ = 'liwei'def application(environ, start_response): start_response('200 ok',[('Content-Type', 'text/html')]) return 'Hello, Web! \r\n\r\nHello, %s!'%(envir

2015-01-05 17:26:18 191

原创 python 学习笔记(二十七)

# coding=utf8__author__ = 'liwei'import mysql.connector'创建连接mysql连接'conn=mysql.connector.connect(user='root',password='root',database='test',use_unicode=True)cursor = conn.cursor()'创建user表'curs

2015-01-05 17:07:49 214

原创 python 学习笔记(二十六)

# coding=utf8__author__ = 'liwei''构造邮件'from email.mime.text import MIMETextmsg = MIMEText('liwei,nihao','plain','utf-8')'输入email地址和密码'from_addr=raw_input('邮箱地址: ')password=raw_input('密码: ')'输

2015-01-05 15:49:43 191

原创 python 学习笔记(二十五)

tcp_server.py# coding=utf8__author__ = 'liwei'import socket,threading,time'创建一个socket's=socket.socket(socket.AF_INET,socket.SOCK_STREAM)s.bind(('127.0.0.1',11224))s.listen(5)print('等待客户端接入..

2015-01-05 15:21:43 245

原创 python 学习笔记(二十四)

# coding=utf8__author__ = 'liwei'from collections import namedtupleimport hashlibimport itertoolsimport time'常用的内建模块collections提供了集合类的许多方法'Point = namedtuple('Point',['x','y'])p=Point(3,5)

2015-01-04 11:44:22 166

原创 python 学习笔记(二十四)

# coding=utf8__author__ = 'liwei'from collections import namedtupleimport hashlibimport itertoolsimport time'常用的内建模块collections提供了集合类的许多方法'Point = namedtuple('Point',['x','y'])p=Point(3,5)

2015-01-04 11:42:49 169

原创 python 学习笔记(二十三)

# coding=utf8__author__ = 'liwei'import re'python正则的应用,math方法判断正则是否匹配成功'print('正则简单用例')text ='hello liwei is 25'if re.match(r'\w+\s+\w+\s+\w+\s+\d+',text): print('ok')else: print('

2014-12-31 15:10:04 253

原创 python 学习笔记(二十二)

# coding=utf8__author__ = 'liwei'import threading ,time,random'多线程的例子'def loop(): print('threading is %s runing'% threading.current_thread().name) n=0 while n<5: n=n+1

2014-12-31 15:09:22 276

翻译 simhash算法原理和代码实现

Simhash传统IR领域内文本相似度比较所采用的经典方法是文本相似度的向量夹角余弦,其主要思想是根据一个文章中出现词的词频构成一个向量,然后计算两篇文章对应向量的向量夹角。但由于有可能一个文章的特征向量词特别多导致整个向量维度很高,使得计算的代价太大,对于Google这种处理万亿级别的网页的搜索引擎而言是不可接受的,simhash算法的主要思想是降维,将高维的特征向量映射成一个f-bit的指

2014-12-30 11:47:51 691

原创 python 学习笔记(二十一)

# coding=utf8__author__ = 'liwei''windows平台多进程导入multiprocessing模块'from multiprocessing import Process,Queuefrom multiprocessing import Poolimport os,time,randomdef run(name): print('Run chi

2014-12-29 17:45:27 210 1

原创 python 学习笔记(二十)

# coding=utf8__author__ = 'liwei'try: import cPickle as pickleexcept ImportError: import pickleimport json'序列化'd = dict(name='liwei',age='25',score=80)print('序列化为字符串写入到文件')pickle.d

2014-12-29 16:23:21 156

原创 python 学习笔记(十九)

# coding=utf8__author__ = 'liwei'import os'查看操作系统'a=os.nameprint(a)'查看操作系统的环境变量'b=os.environprint(b)'查看操作系统指定目录'c = os.listdir('e:\Program Files (x86)')print(c)

2014-12-26 16:33:30 188

原创 python 学习笔记(十八)

# coding=utf8__author__ = 'liwei'print('读文件')f = open('E:\keywords.txt')print(f.read())f.close()'对上面的代码优化''写文件'with open('E:\keywords.txt','w') as w: w.write('liwei\n') w.write('lizha

2014-12-26 15:42:22 162

原创 python 学习笔记(十七)

# coding=utf8__author__ = 'liwei''日志模块来记录错误'import logging'python异常处理机制'try: print('python异常处理机制:try') r =10/0 c =10/int('a') print('result:',r)except ZeroDivisionError,e:

2014-12-26 14:49:25 194

原创 python 学习笔记(十六)

type13_1.py# coding=utf8__author__ = 'liwei'class Hello(object): def hello(self,name='word'): print('Hello %s'%name)type13_2.py# coding=utf8__author__ = 'liwei''导入type13_1.py模块

2014-12-24 17:26:57 147

原创 python 学习笔记(十五)

# coding=utf8__author__ = 'liwei''导入type13_1.py模块'from type13_1 import Helloh=Hello()h.hello()'查看类型'print(type(Hello))print(type(h))print(type(h.hello()))'使用type()函数创建类,的用法'print('使用type()

2014-12-23 18:00:25 198

原创 python 学习笔记(十四)

# coding=utf8__author__ = 'liwei''定制类的练习'class Student(object): def __init__(self,name): self.name=namea=Student('liwei')print(a)'_str_对以上例子的使用'print('_str_对以上例子的使用')class Stud

2014-12-23 16:51:48 202

原创 python 学习笔记(十三)

#!/usr/bin/env python# coding=utf8'继承的练习'print('继承的练习')class Anima(object): def run(self): print '我在跑' def talk(self,call): print '我在叫%s'%callclass Dog(Anima): pa

2014-12-12 15:43:00 179

原创 MongoDB 的基本常用操作

MongoDB数据表基本操作查看全部数据表> use ChatRoomswitched to db ChatRoom> show collectionsAccountChatsystem.indexessystem.users创建数据表> db.createCollection("Account"){"ok":1} > db.createColl

2014-12-11 09:39:43 291

原创 python 学习笔记(十二)

#!/usr/bin/env python# coding=utf8import functools'装饰器的运用'print("一般运用在定义了一个函数但又不希望修改函数的定义,这种在代码运行期间动态增加功能的方式,称之为“装饰器”(Decorator)")def name(): print("liwei")#@logn =name()'运行有问题请大神看看'

2014-12-09 17:53:54 189

原创 scrapy爬取数据的时候的一个颜色输出很有用

安装 termcolor 模块pip install termcolor结果如图:

2014-12-08 17:53:50 639

原创 linux 下升级python版本

首先下载源tar包  可利用linux自带下载工具wget下载,如下所示:1# wget http://www.python.org/ftp/python/3.3.0/Python-3.3.0.tgz  或自己去网上找,这里提供一个最新版的下载链接:http://xiazai.zol.com.cn/detail/3

2014-12-08 17:04:43 231

原创 scrapy分布式的应用学习笔记(一)

1. 创建项目,在项目目录执行命令 scrapy startproject webbot 生成下面的目录和文件 scrapy.cfg: 项目配置文件webbot//: 项目的 python 源代码 modulewebbot//items.py: 定义 item 类,用来存储爬取的数据.webbot//pipelines.py: pipelines文件,定义清洗,处理数据的类webbot

2014-12-06 21:09:08 363

原创 关于 twisted.internet.error.CannotListenError 报错

关于运行scrapyd服务时报错twisted.internet.error.CannotListenError: Couldn't listen on 0.0.0.0:6800: [Errno 98] Address already in use.解决办法:在运行scrapyd试试:

2014-12-05 21:52:53 2133

原创 Ubuntu下配置samba实现文件夹共享

Ubuntu下配置samba实现文件夹共享一. samba的安装:sudo apt-get insall sambasudo apt-get install smbfs二. 创建共享目录:mkdir /home/phinecos/sharesodu chmod 777 /home/phinecos/share三. 创建Sa

2014-12-05 12:55:22 255

原创 python 学习笔记(十一)

# coding=utf8print('python关于类的应用')class Student(object): def __init__(self,name,age): self.name = name self.age = age def print_name(self): print('%s,%s' %(self.na

2014-12-03 17:33:27 152

原创 python 学习笔记(十)

# coding=utf8from __future__ import divisionprint("__future__模块,把下一个新版本的特性导入到当前版本,于是我们就可以在当前版本中测试一些新版本的特性。")print('10/3 =',10/3)print('10.0/3=',10.0/3)print('10//3=',10//3)

2014-12-03 11:54:13 173

原创 python 学习笔记(九)

# coding=utf8import Imageimport sysprint(u"第三方模块的联系")im = Image.open('1.png')print(im)print im.format,im.size,im.modeprint(u"thumbnail方法将按比例生成图片略缩图")im.thumbnail((200, 100))im.save('2

2014-12-03 11:52:42 163

原创 python 学习笔记(八)

# coding=utf8print(u"作用域private的应用于范围的使用")'作用域private的应用于范围的使用'def _private1(name): return "nihao %s" %namedef _private2(name): return "hello %s" %namedef getname(name): if l

2014-12-01 18:09:50 189

原创 python 学习笔记(七)

片段一:#coding: UTF-8print (u"sys模块的的导入与使用")import sysprint(u'sys模块里argv变量,用list存储了命令行的所有参数。argv至少有一个元素,因为第一个参数永远是该.py文件的名称')def test(): args = sys.argv if len(args)==1: pr

2014-12-01 18:07:52 162

原创 python 学习笔记(六)

# map()和reduce()函数用法的深入了解,高阶函数#map()函数接受两个参数,一个函数本身和一个序列def n(x): return x*xa = map(n, [1,2,3,4,5])print 'map()函数接受两个参数,一个函数本身和一个序列:'print 'a = map(n, [1,2,3,4,5])'print a#reduce

2014-12-01 11:21:25 199

原创 python 学习笔记 (五)

#递归函数,如果一个函数在内部调用自身本身,这个函数就是递归函数。#该包下的Iterable方法是用来判断对象是否可以迭代from collections import Iterable#递归算阶乘def fact(n): if n ==1: return 1 return n *fact(n-1)

2014-12-01 11:20:48 195

原创 python 学习笔记(四)

#循环例子# 导入os模块,模块的概念后面讲到import os#if - else判断语句num =18if num >= 18: print '恭喜你已经成年!' elif num =6: print '你还在上学呢吧!' else: print '你还没到上小学呢!' #for in 循环

2014-12-01 11:19:35 166

原创 python 学习笔记(三)

#cmp比较函数的用法#比1大返回-1print cmp(1, 2)#和1相等返回0print cmp(1, 1)#比2小返回1print cmp(2, 1)#def函数定义,自己写的简单算绝对值的方法。def my_abs(x): if x>= 0: return x else:

2014-12-01 11:18:43 203

原创 python 学习笔记 (二)

#dict 字典 在其他语言中也称为map 使用key-value(键和值)不能有重复的值a = {'liwei':25,'lizhao':25,30:32,'wangfengfeng':22,'liwei':25}print a print a[30]#d = {'Michael': 95, 'Bob': 75, 'Tracy': 85}#print d['Michael'

2014-12-01 11:17:36 240

原创 python 学习笔记(一)

#数据的格式化import math#%s 代表字符串 %d代表整数 %f 代表浮点print 'hello %s,my age :%d'%('word',25)print '%.4f'%(math.pi)#两个%%代表%print '%d%%'%(7)#数组操作相关a = [1,2,3,4,'liwei','lizhao','wangfengfeng']#pop方法从数组

2014-12-01 11:14:56 198

windows下安装scarpy的所有依赖包

windows下安装scarpy的所有依赖包已经打包好了~会解决你意想不到的好多问题!

2014-11-25

从程序员到CTO的Java技术路线图

详细说明了从一个菜鸟JAVA程序员到CTO的路线和需要掌握的所有技术。

2013-06-10

本地播放器ActionScript 3.0实现

本地播放器ActionScript 3.0实现java实现的源代码供大家参考!

2012-05-01

eclipse+3.6.2汉化包.rar

eclipse+3.6.2汉化包汉化eclipse的英文界面~

2012-05-01

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除