位置参数
来源:互联网 发布:淘宝德国进口净水器 编辑:程序博客网 时间:2024/05/16 14:38
位置参数必须在被调用函数中定义的准确顺序来传递。
>>> def foo(who): #defined for only 1 argument
print("hello",who)
>>> foo() #o argument ..BAD
Traceback (most recent call last):
File "<pyshell#350>", line 1, in <module>
foo()
TypeError: foo() missing 1 required positional argument: 'who'
>>> foo("word!") #1 argument ...WORKS
hello word!
>>> foo("MR.","Word!") #2 arguments ...BAD
Traceback (most recent call last):
File "<pyshell#352>", line 1, in <module>
foo("MR.","Word!")
TypeError: foo() takes 1 positional argument but 2 were given
foo()函数有一个位置参数。意味着任何对foo()的调用必须有唯一的一个参数,不多不少。否则会频频看到TypeError。
- 位置参数
- linux之位置参数
- bash 位置参数
- set --设置位置参数
- 位置变量参数
- Shell位置参数
- Linux位置参数变量
- Qualcomm音频参数位置
- request_irq参数及位置
- SHELL位置参数
- Linux shell位置参数
- RelativeLayout 位置参数
- Bash shell位置参数
- shell 的位置参数
- linux:位置参数变量
- View的位置参数
- Linux 位置参数变量
- 位置参数变量
- duilib把MFC窗口作为控件时出现错误
- 安装和使用vsphere问题总结+可能会持续更新
- 帝国-标签模板支持的变量
- Execution failed for task :mergeDebugResources
- Python(16):所谓的“函数指针”
- 位置参数
- 内存分配—malloc()和free()
- 学习资源,干货!!!JAVA大全
- 操作系统处理机调度及常见的调度算法
- android 在多线程中运用的Toast
- 数据库的基本操作
- Androidstudio使用笔记
- 查看jdk的版本以及路径
- jQuey在MyEclipse中不起作用的解决方法