摘要:
简介如何在php中方便地解析html代码,估计是每个phper都会遇到的问题。用phpQuery就可以让php处理html代码像jQuery一样方便。项目地址:https://code.google.com/p/phpquery/github地址:https://github.com/Tobiasz... 阅读全文
摘要:
一、Flask简介Flask 是一个 Python 实现的 Web 开发微框架。官网:http://flask.pocoo.org/二、Demo1、代码结构.├── blog.py├── static│ ├── css│ │ └── index.css│ ├── images│ │ ├── cat.... 阅读全文
摘要:
demo#!/usr/bin/pythonclass Person: name = 'jim' age = 25 def say(self): print 'My name is ' + self.name + ', and age is ' + str(self.a... 阅读全文
摘要:
一、安装MySQL-python# yum install -y MySQL-python二、打开数据库连接#!/usr/bin/pythonimport MySQLdbconn = MySQLdb.connect(user='root',passwd='admin',host='127.0.0.1... 阅读全文
摘要:
一、语法#!/usr/bin/pythonfilename='hello'#try except finally demotry: open('abc.txt') print helloexcept IOError,msg: print 'the file not exist'ex... 阅读全文
摘要:
本文不涉及正则表达式本身的内容,只记一下python中正则的用法及常用方法。一、re模块python中用re模块进行正则处理>>>import re>>>s = r'abc'>>>re.findall(s,'aaaabcaaaaa')['abc']或先编译(会更快):>>> import re>>>... 阅读全文
摘要:
一、文件的打开和创建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... 阅读全文
摘要:
原理浅拷贝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>>> ... 阅读全文
摘要:
一、数学相关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... 阅读全文
摘要:
一、模块用import导入cal.py:#!/usr/bin/pythondef add(x,y): return x+yif __name__ == '__main__': print add(1,2)注:__name__为内置变量,如果直接在CLI中调用值为__mail__,否则为文... 阅读全文