python 函数参数
2015-07-13 14:25
706 查看
#!/usr/bin/python2.6 # -*- coding: utf-8 -*- def parameters(arg1,arg2,key1=1,key2=2,*arg,**keywords): print "arg1",arg1 print "arg2",arg2 print "key1 %d"%key1 print "key2 %d"%key2 print "*arg",arg print "**keywords",keywords parameters(1,2,3,4,5,6,k1=1,k2=2,k3=3)
#arg1 1
#arg2 2
#key1 3
#key2 4
#*arg (5, 6)
#**keywords {'k3': 3, 'k2': 2, 'k1': 1}
#arg1普通参数(必填参数),key1默认参数(如不填就使用默认值),*arg非关键参数(可变参数接收的是一个tuple),**关键参数接收的是一个dict。
相关文章推荐
- Python3.2官方文件翻译-工具列表和十进制浮点计算
- python第一个爬虫
- python第三方库系列之十八--python/django test库
- Python三种结构
- 【Python 学习手册笔记】动态类型简介
- strategy pattern in Python
- Python: Unable to find vcvarsall.bat 解决方法
- python 加密解密
- Python学习笔记
- Notepad++调试运行Python脚本方法
- python加载图片
- python inconsistent dedent(不一致的缩进)
- python编译as
- python入门读书笔记
- 第一个Python小程序
- python 中得 “=”
- Python+Numpy+Scipy+Matplotlib+IPython(一)
- python写中文utf-8编码csv文件
- python读取中文gbk编码json文件
- Python 3.4 install lxml