python中可变参数个数参数
2013-04-13 21:57
330 查看
args
Table of Contents
1 python中可变参数1.1 以tuple类型传递
1.2 以dict类型传递
1 python中可变参数
1.1 以tuple类型传递
def argTest(*args): print(args, type(args)) for i in args: print(i) argTest(1,2,3) argTest(1, "Hello") => (1, 2, 3) <class 'tuple'> 1 2 3 (1, 'Hello') <class 'tuple'> 1 Hello
1.2 以dict类型传递
def keyArgTest(**args): print(args, type(args)) for k,val in args.items(): print(k,val) keyArgTest(k1=1,k2='123',k3=12.4) => {'k1': 1, 'k3': 12.4, 'k2': '123'} <class 'dict'> k1 1 k3 12.4 k2 123
Date: 2013-04-13 22:01:37 中国标准时间
相关文章推荐
- 【Python-3.3】函数中的可变参数和关键字参数
- C++ Has Become More Pythonic ( tuple & 可变模板参数 )
- 避免可变参数的修改(关键词:Python/可变参数)
- python函数的参数定义和可变参数
- Python函数可变参数*args及**kwargs详解
- python 可变参数
- Python中函数的参数传递与可变长参数
- python--通过可变参数计算n个数的乘积
- Python class 初始化参数为 list 等 可变类型时遇到的问题
- Python中函数的参数定义和可变参数
- Python中函数的参数定义和可变参数
- Python新手学习基础之函数-可变参数**
- Python可变参数
- Python定义可变参数
- Python——可变类型与不可变类型(即为什么函数默认参数要用元组而非列表)
- [Python学习笔记-004] 可变参数*args和**kwargs
- Noah的学习笔记之Python篇:函数“可变长参数”
- 关于python函数的可变参数和关键词参数
- python 可变参数和lambda
- python中的可变参数 【*args】和【**kwargs】