1、python函数参数(含星号参数)
http://blog.useasp.net/archive/2014/06/23/the-python-function-or-method-parameter-types.aspx
一个星号:
多余的参数将自动被放入元组中提供给函数使用
eg:
def
func(arg1, arg2,
*
args):
print
arg1, arg2, args
func(
"hello"
,
"Tuple, values is:"
,
2
,
3
,
3
,
4
)
Output:
hello Tuple, values is: (2, 3, 3, 4)
## 调用的时候,前面两个必须在前面
两个星号:
多余的参数将自动被放入字典中提供给函数使用
eg:
def
func(arg1, arg2,
*
*
kwargs):
print
arg1, arg2, kwargs
func(
"hello"
,
"Dict, values is:"
, x
=
2
, y
=
3
, z
=
3
)
func(
"hello"
,
"Dict., values is:"
,
*
*
{
'x'
:
2
,
'y'
:
3
,
'z'
:
3
})
Output:
hello Dict., values is: {'y': 3, 'x': 2, 'z': 3}
## 如果你需要直接传递字典给函数,需要在传递的过程中添加**
2、python字符串 单引号,双引号,三引号
http://woodpecker.org.cn/abyteofpython_cn/chinese/ch04s03.html
3、字符串前加r,消除转义
r/R | 原始字符串 - 原始字符串:所有的字符串都是直接按照字面的意思来使用,没有转义特殊或不能打印的字符。 原始字符串除在字符串的第一个引号前加上字母"r"(可以大小写)以外,与普通字符串有着几乎完全相同的语法。 |
4、operator.itemgetter函数
http://blog.csdn.net/dongtingzhizi/article/details/12068205
http://beginman.cn/python/2015/05/18/python-operator-sorted/
5、迭代器itertools groupby
http://mars914.iteye.com/blog/1985160
6、列表推导式
http://www.cnblogs.com/yupeng/p/3428556.html
7、生成表达式 VS 列表解析
http://www.pythonpub.com/python-iterator2.html
8、排序sort和sorted
http://f.dataguru.cn/thread-40617-1-1.html
9、itertools迭代器模块
http://www.cnblogs.com/cython/articles/2169009.html
10、lambda函数
http://woodpecker.org.cn/diveintopython/power_of_introspection/lambda_functions.html