在flask 的 design 有幾個 concept。
Context (應用下上文) 就是其中一個例子。
The context is typically used to cache resources on there that need to be created on a per-request or usage case. For instance database connects are destined to go there.
peicheng 發表在 痞客邦 留言(0) 人氣(42)
Suffix Arrays
http://algorithmicalley.com/archive/2013/06/30/suffix-arrays.aspx
peicheng 發表在 痞客邦 留言(0) 人氣(4)
python str unicode
str.decode('utf-8') -> unicode
從 ascii 轉成 unicode
peicheng 發表在 痞客邦 留言(0) 人氣(62)
在 python 裡面split 使用 multiple delimiters 可以使用 re
import re
re.split(',|.')
peicheng 發表在 痞客邦 留言(0) 人氣(25)
有時候使用外部指令來 執行 python的程式,
想要取得該程式 的 實際路徑位置
可以使用 os.path.abspath(__file__) 來獲取 路徑位置的資訊。
peicheng 發表在 痞客邦 留言(0) 人氣(57)
使用 MySQLdb 連結到 MySQL
有幾點值得注意
盡量都使用utf-8編碼,確保 中文 可以順利 insert進去
若是為select fetchall時出來的 data 是unicode
peicheng 發表在 痞客邦 留言(0) 人氣(28)
稍微做了一個測試把一個字典檔載入到dict裡面,
結構為 dict[term]=詞頻
$ ls -al /usr/local/lib/python2.7/dist-packages/jieba-0.30-py2.7.egg/jieba/dict.txt
-rw-r--r-- 1 root staff 8583143 7月 15 16:11 /usr/local/lib/python2.7/dist-packages/jieba-0.30-py2.7.egg/jieba/dict.txt
peicheng 發表在 痞客邦 留言(0) 人氣(38)
est
11:12 (23 小時前)
寄給 python-cn
解决GIL 那是不可能的事情。本菜就来总结下:
1. C/C++ 手动管理。
2. perl 重来都是fork
3. tcl / lua 一个core一个解释器
4. erlang 复制为王
5. Ruby 也有GIL
6. JVM - fine grained lock。
总的来说,GIL 是个被严重夸大的问题,
为啥喷子就不去喷Go语言的GOMAXPROCS啊????整天把一个跑单核的Go语言当成宝了。
peicheng 發表在 痞客邦 留言(0) 人氣(16)
- WSGI a specification for Python web applications Werkzeug follows
Python Web Server Gateway Interface (WSGI).
#WSGI
This document specifies a proposed standard interface between web servers and Python web applications or frameworks, to promote web application portability across a variety of web servers.
peicheng 發表在 痞客邦 留言(0) 人氣(18)
[python] python OCR
temp to write 130529
peicheng 發表在 痞客邦 留言(0) 人氣(9)