Python基础知识小结
1. 关于函数传参
def func(n, *args, **kwargs): print n print args print kwargs if __name__ == '__main__': # func(2, 5,7,9, m = 1, q = 0) n = 2 args = (5, 7, 9) kwargs = {'m':1, 'q':0} func(n, args, kwargs) func(n, *args, **kwargs) func(n=n, args=args, kwargs=kwargs)
运行结果:
2 ((5, 7, 9), {'q': 0, 'm': 1}) {} 2 (5, 7, 9) {'q': 0, 'm': 1} 2 () {'args': (5, 7, 9), 'kwargs': {'q': 0, 'm': 1}}
剩下内容请查看:http://note.youdao.com/noteshare?id=25bf27e8001000b989140e4e3722737b