摘要: 简介如何在php中方便地解析html代码,估计是每个phper都会遇到的问题。用phpQuery就可以让php处理html代码像jQuery一样方便。项目地址:https://code.google.com/p/phpquery/github地址:https://github.com/Tobiasz... 阅读全文
posted @ 2015-01-06 10:16 观海云不远 阅读(879) 评论(0) 推荐(0) 编辑
摘要: 一、Flask简介Flask 是一个 Python 实现的 Web 开发微框架。官网:http://flask.pocoo.org/二、Demo1、代码结构.├── blog.py├── static│ ├── css│ │ └── index.css│ ├── images│ │ ├── cat.... 阅读全文
posted @ 2014-12-31 14:11 观海云不远 阅读(2872) 评论(0) 推荐(0) 编辑
摘要: demo#!/usr/bin/pythonclass Person: name = 'jim' age = 25 def say(self): print 'My name is ' + self.name + ', and age is ' + str(self.a... 阅读全文
posted @ 2014-12-31 13:53 观海云不远 阅读(337) 评论(0) 推荐(0) 编辑
摘要: 一、安装MySQL-python# yum install -y MySQL-python二、打开数据库连接#!/usr/bin/pythonimport MySQLdbconn = MySQLdb.connect(user='root',passwd='admin',host='127.0.0.1... 阅读全文
posted @ 2014-12-29 19:10 观海云不远 阅读(274) 评论(0) 推荐(0) 编辑
摘要: 一、语法#!/usr/bin/pythonfilename='hello'#try except finally demotry: open('abc.txt') print helloexcept IOError,msg: print 'the file not exist'ex... 阅读全文
posted @ 2014-12-29 16:26 观海云不远 阅读(318) 评论(0) 推荐(0) 编辑
摘要: 本文不涉及正则表达式本身的内容,只记一下python中正则的用法及常用方法。一、re模块python中用re模块进行正则处理>>>import re>>>s = r'abc'>>>re.findall(s,'aaaabcaaaaa')['abc']或先编译(会更快):>>> import re>>>... 阅读全文
posted @ 2014-12-26 16:32 观海云不远 阅读(515) 评论(0) 推荐(0) 编辑
摘要: 一、文件的打开和创建1、打开open(file,mode):>>>fo = open('test.txt', 'r')>>>fo.read()'hello\n'>>>fo.close()file(file,mode):>>>f = file('test.txt', 'r')>>>f.read()'h... 阅读全文
posted @ 2014-12-24 09:47 观海云不远 阅读(528) 评论(0) 推荐(0) 编辑
摘要: 原理浅拷贝import copyb = copy.copy(a)demo:>>> a=[1,['a']]>>> b=a>>> c=copy.copy(a)>>> a[1, ['a']]>>> b[1, ['a']]>>> c[1, ['a']]>>> id(a)140556196249680>>> ... 阅读全文
posted @ 2014-12-23 17:42 观海云不远 阅读(335) 评论(0) 推荐(0) 编辑
摘要: 一、数学相关1、绝对值:abs(-1)2、最大最小值:max([1,2,3])、min([1,2,3])3、序列长度:len('abc')、len([1,2,3])、len((1,2,3))4、取模:divmod(5,2)//(2,1)5、乘方:pow(2,3,4)//2**3/46、浮点数:rou... 阅读全文
posted @ 2014-12-23 17:15 观海云不远 阅读(422) 评论(0) 推荐(0) 编辑
摘要: 一、模块用import导入cal.py:#!/usr/bin/pythondef add(x,y): return x+yif __name__ == '__main__': print add(1,2)注:__name__为内置变量,如果直接在CLI中调用值为__mail__,否则为文... 阅读全文
posted @ 2014-12-23 11:48 观海云不远 阅读(503) 评论(0) 推荐(0) 编辑