[git]显示单个文件变更日志

Date Category git Tags git

git log -p filename:

$ git log -p fabfile.py
commit fd792030bc0ac1db0f1f97ec701a2fd8bcb26a07
Author: username <email>
Date:   Sun Jun 23 15:36:58 2013 +0800

    commit title

diff --git a/fabfile.py b/fabfile.py
index 4ed36fa..1408118 100644
--- a/fabfile.py
+++ b/fabfile.py
@@ -9,28 +9,29 @@ from fabric.api ...
more ...

[python]统计列表中重复项的出现次数

列表项由数字、字符串组成,统计重复项:

>>> from collections import defaultdict
>>> d = defaultdict(int)
>>> for x in [1, 2, 3, 1, 2, 3, 1]:
...     d[x] += 1
...
>>> dict(d)
{1: 3, 2: 2, 3: 2}
>>>
>>> c = defaultdict(int)
>>> for y in ['a', 'b', 'a', 'c', 'c']:
...     c[y] += 1
...
>>> dict(c)
{'a': 2, 'c ...
more ...