Python 編碼
- a = u'ab'
b = "ab"
如何互轉(zhuǎn)? - unicode聲明
# -*- coding: utf-8 -*-
join unicode
用chardet檢測編碼格式
Python編碼
類型
python的函數(shù)特性
- map
pyquery
https://pypi.python.org/pypi/pyquery
api : http://pyquery.readthedocs.org/en/latest/api.html
TypeError: Type 'unicode' cannot be serialized.
給兩個list,一個是word list, 一個是prefix list return 所有的word that have the prefix 例子: word list = [“a", "abc", "dz", "dda], prefix list = ["ab", "dd"] return ["abc", "dda"]
Python干貨精選 http://baoz.me/446252
當(dāng)我說我會Python時,實(shí)際上我會了什么?
遍歷目錄
os.walk
import os,sys
for root, dirs, files in os.walk("."):
for f in files:
fullpath = "%s/%s" % (root, f)
if fullpath.endswith("java"):
print fullpath
#os.system("dos2unix " + fullpath)
temp = fullpath[:-1]
#command = "expand -t 4 " + fullpath + " > " + temp
command = "rm -rf " + fullpath
command = "sed -i 's/ *$//' " + fullpath
#print command
os.system(command)
性能:
High Performance Python: Practical Performant Programming for Humans
profile:
7 個測量 Python 腳本和控制內(nèi)存以及 CPU 使用率的技巧
random
常用模塊
bitarray : bit操作
profile:
memory_profiler
awesome-python : https://github.com/vinta/awesome-python
python-books:
how to think like a computer scientist : http://www.greenteapress.com/thinkpython/thinkCSpy.pdf
算法
python 字典(dict)按鍵和值排序
http://www.cnpythoner.com/post/266.html
Python數(shù)據(jù)結(jié)構(gòu)
集合
https://docs.python.org/2/library/stdtypes.html#set
hash表:
dict:
https://docs.python.org/2/library/stdtypes.html#dict
高階函數(shù):
functools: https://docs.python.org/2/library/functools.html
函數(shù)嵌套:
http://effbot.org/pyfaq/how-do-you-make-a-higher-order-function-in-python.htm
列表
連接列表
[1 ,2, 3 ] + [4, 5, 6] = [1, 2, 3, 4, 5, 6]
列表生成
http://www.cnblogs.com/moinmoin/archive/2011/03/10/lsit-comprehensions-generators.html
Pip
hash not match: http://stackoverflow.com/questions/16025788/why-does-pip-fail-with-bad-md5-hash-for-package#