WSGI 是Web Services Gateway Interface的缩写. 如果想深入了解,可以阅读 PEP
333 文档,包含有任何你想要的:)community errata, .这篇文章将手把手教你写一个简单的WSGI例子。
注意:我用的Python版本是.2.7.x.
最经典,最简答的WSGI样当属 Hello
World app.
咱们将要用到 v...
分类:
其他好文 时间:
2014-07-22 23:03:53
阅读次数:
407
在Python中内部所有编码都是Unicode,Unicode属于中转码,一般来说,是先把乱码转化为中转码,再转化为我
们需要的编码,转换过程为decode -> unicode -> encode。
#coding:utf-8
#-*- coding:utf-8 -*-
import sys
print sys.getdefaultencoding()
print '中国'
f =...
分类:
编程语言 时间:
2014-07-22 23:03:34
阅读次数:
368
今天学习如何利用Python来解析XML文档。
给定一个XML文件,现在我们用Python来提取里面的内容。
11111111
120
15.0
Python代码:
import xml.etree.ElementTree as ET...
分类:
编程语言 时间:
2014-07-22 23:02:14
阅读次数:
322
oracle@ywdb ~]$ sqlplus "/as sysdba"
SQL*Plus: Release 11.1.0.7.0 - Production on Tue Apr 29 15:40:38 2014
Copyright (c) 1982, 2008, Oracle. All rights reserved.
Connected to:
Oracle Data...
分类:
数据库 时间:
2014-07-22 23:01:54
阅读次数:
435
Little Vasya has received a young builder’s kit. The kit consists of several wooden bars, the lengths of all of them are known. The bars can be put one on the top of the other if their lengths are the...
分类:
其他好文 时间:
2014-07-22 23:01:53
阅读次数:
323
1. 让你的脚本再多打印一行
2、让你的脚本只打印一行...
分类:
编程语言 时间:
2014-05-01 08:38:53
阅读次数:
312
数学和数学计算
print 25+30/6 #25加上30除以6 和为39
print 100-25*3%4 #100减去25乘以3的积再除以4的余数,就是100-3=97
print 100%16 #100除以16的余数=4
print 1/4 #1除以4,然后因为是整数,所以四舍5入为0
print 1.0/4.0 ##1.0除以4.0,因为是浮点数,所以等于0.25
print 3+5...
分类:
编程语言 时间:
2014-05-01 08:22:53
阅读次数:
653
1 Yield生成器
Yield是我在其他语言中没有见过的一个属性,算是python的一大特色,用好之后可以使代码更简洁。考虑一个简单的例子,文件的遍历。要遍历一个目录下的所有文件需要递归的操作。如果我们只是单纯的打印文件名,我们可以在递归的过程中完成,每当发现一个非目录就可以打印文件名。代码如下:
class TraverseDirectory(object):
@s...
分类:
编程语言 时间:
2014-04-30 22:48:40
阅读次数:
312
关于最大熵模型的介绍请看:http://www.cnblogs.com/hexinuaa/p/3353479.html
下面是GIS训练算法的python实现,代码不到100行。
from collections import defaultdict
import math
class MaxEnt(object):
def __ini...
分类:
其他好文 时间:
2014-04-30 22:46:39
阅读次数:
384