python
文章平均质量分 70
warrior_zhang
这个作者很懒,什么都没留下…
展开
-
python 利用selenium模拟登录帐号验证网站并获取cookie
python 利用selenium模拟登录帐号验证网站并获取cookie 1.安装selenium package:2.引入selenium package, 建立webdriver对象:3。打开设定的url,并等待response:4.通过xpath找到登录框,并填入相应帐号密码,模拟点击登录:5.验证登录成功与否,若currenturl发生变化,则认为登录成功:6.通过对象的方法获取当前访问网站的session cookie:7.得到cookie之后,就可以通过urllib2访问相应的网原创 2015-12-06 21:44:39 · 32047 阅读 · 4 评论 -
The error in python :ImportError: No module named xxx
只要出现ImportError 错误就说明有一个包缺失。在本例中,我们安装的networkx 模块有一个未作处理的依赖项——numpy ,它是一个高度优化的科学计算工具集。通常,再次调用easy_install 就可以解决这个问题,处理numpy 缺失的方法与安装NetworkX 的方法一样。只要关闭解释器,并且在终端输入easy_install numpy 即可安装该依赖项. The error in python :ImportError: No module named xxx原创 2016-01-12 13:02:07 · 4664 阅读 · 0 评论 -
example for document classify use nltk and python
example for document classify use nltk and python1. get the movie comment and classify it into pos or neg原创 2016-01-12 13:02:14 · 465 阅读 · 0 评论 -
RegExp and classfier used in part-of-speech(POS) tagging
1. regular expression in pos judge the characteristic of a certain word by suffix pattern matching原创 2016-01-12 13:02:17 · 519 阅读 · 0 评论 -
Python 字典(Dictionary) setdefault()方法
描述 Python 字典(Dictionary) setdefault() 函数和get()方法类似, 如果键不已经存在于字典中,将会添加键并将值设为默认值。 语法 setdefault()方法语法: 点击(此处)折叠或打开 dict.setdefault(key, d原创 2016-01-12 13:02:32 · 1857 阅读 · 0 评论 -
python 列表/元组/字典
1.Python列表List(列表) 是 Python 中使用最频繁的数据类型。 列表可以完成大多数集合类的数据结构实现。它支持字符,数字,字符串甚至可以包含列表(所谓嵌套)。 列表用[ ]标识。是python最通用的复合数据类型。看这段代码就明白。 列表中的值得分割也可以用到变量[头下标:尾下标],就可以截取相应的列表,从左到右索引默认0开始的,从右到左索引默原创 2016-01-12 13:02:37 · 446 阅读 · 0 评论 -
python 单行注释/多行注释/代码间注释/特殊注释/"""doc String
1.单行注释python中单行注释采用 #开头 点击(此处)折叠或打开 #!/usr/bin/python #filename: searchengine.py #input: onne #output: none原创 2016-01-12 13:02:40 · 2220 阅读 · 0 评论 -
深入理解python之self
首先明确的是self只有在类的方法中才会有,独立的函数或方法是不必带有self的。self在定义类的方法时是必须有的,虽然在调用时不必传入相应的参数。 self名称不是必须的,在python中self不是关键词,你可以定义成a或b或其它名字都可以,但是约定成俗,不要搞另类,大家会不明白的。下例中将self改为myname一样没有错误: 点击(此处)折叠或打原创 2016-01-12 13:02:56 · 3616 阅读 · 0 评论 -
install pysqlite in ubuntu
1. download the source package from below:https://pypi.python.org/simple/pysqlite/orhttps://github.com/ghaering/pysqlite2.unzip and install unzip 点击(此处)折叠或打开原创 2016-01-12 13:02:59 · 779 阅读 · 0 评论 -
error: sqlite3.h: No such file or directory #include "sqlite3.h"
Before you install "pysqlite" you have to install sqlite at first!!点击(此处)折叠或打开 sudo apt-get install sqlite3 sudo apt-get install libsqlite3-dev原创 2016-01-12 13:03:05 · 6061 阅读 · 0 评论 -
python中的接口
什么是接口 ?接口只是定义了一些方法,而没有去实现,多用于程序设计时,只是设计需要有什么样的功能,但是并没有实现任何功能,这些功能需要被另一个类(B)继承后,由 类B去实现其中的某个功能或全部功能。转载 2016-01-12 13:03:08 · 1442 阅读 · 0 评论 -
set() in python
1. set() remove the repeat elements2.set集合操作原创 2016-01-12 13:03:11 · 705 阅读 · 0 评论 -
深入理解Python的字符编码utf-8 & unicode
在Python中有两个和字符很相关的类型,一个是str类型,一个是unicode类型。这两种类型的对象都是sequece序列,其中str是字节序列,而unicode是字符序列在2.x版本的python中,默认定义的字符串是str类型的。在Python中和编码相关的两个函数为decode和encode在Java中你也会发现这两个类似的方法。转载 2016-01-12 13:03:13 · 6297 阅读 · 0 评论 -
urllib2中的两个重要概念 Openers和Handlers
1.urllib2的基本功能urlopen() 这个方法返回一个request对象,栗子如下:上面栗子中的url或者realurl可能会不同,因为初始连接可能会经过跳转。2.urllib2中的opener 我们能直接使用urllib2.urlopen(),是因为有一个默认的(default)opener对象,然而默认的它是适合普通应用的,如果要用一些高级点的功能像HTTPRedirectHandler、HTTPCookieProcessor,这时候就需要自定义一款opener啦,方法如下原创 2016-01-12 13:03:18 · 428 阅读 · 0 评论 -
file operate in python (open write read close )
1. file open: fd = open(N1,N2):N1:path of the file to be open like '/home/warrior/Downloads/test.txt' N2:some choiceable parameter原创 2016-01-12 13:01:20 · 632 阅读 · 0 评论 -
I/O of python (INPUT / OUTPUT)
1. OUTPUT: 1)standard output . expression or print like:>>>2*3+4 10 >>>result = 2*3+4 >>>print result 10 2)file原创 2016-01-12 13:01:23 · 491 阅读 · 0 评论 -
正则表达式
1. 符号应用\、{}、()、| \:转意符 {}:标定匹配字符长度 (A|B):匹配A或者B二选其一 例子:re.search('^[a-z]{5,}-[a-z]{2,3}-(ed|ing)$') 反馈:'zhang-ton-ing' 匹配条件:以小写字母开头^[a-z] 匹配第一段长度原创 2016-01-12 13:01:26 · 1031 阅读 · 0 评论 -
function summary of nltk in python
1. re.findall(regexp,word):find the characters in word by the pattern 'regexp'2. nltk.regexp_tokenize(text,pattern): find the characters in text by the pattern 'pattern' 3. re.split(r',',string):d原创 2016-01-12 13:01:29 · 351 阅读 · 0 评论 -
note of code in python
1.different of assignment variable and list note of code in python原创 2016-01-12 13:02:05 · 286 阅读 · 0 评论