标签:pre func style 知识 war bsp span print 函数
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}}
哈哈哈
标签:pre func style 知识 war bsp span print 函数
原文地址:http://www.cnblogs.com/DarrenChan/p/7931735.html