Python 2.7.10 (default, Oct 14 2015, 16:09:02)
[GCC 5.2.1 20151010] on linux2
Type "copyright", "credits" or "license()" for more information.
>>> def function():定义函数
ptintf("run") >>> function() Traceback (most recent call last):
File "<pyshell#3>", line 1, in <module>
function()
File "<pyshell#2>", line 2, in function
ptintf("run")
NameError: global name 'ptintf' is not defined
>>> def fun():
print ("hello") >>> fun()
hello
>>> def fun2(name):
print(name) >>> fun2(new) Traceback (most recent call last):
File "<pyshell#11>", line 1, in <module>
fun2(new)
NameError: name 'new' is not defined
>>> fun2("new")
new
>>>
>>>
>>> def fun3(num1,num2):
return num1+num2函数的返回值 >>> print (fun3(1,2))
3
>>> def fun4(name)
SyntaxError: invalid syntax
>>> def fun4(name):
'name is a param'
print(name) >>> fun4("hello world")
hello world
>>> fun4._doc_函数的注释文档 Traceback (most recent call last):
File "<pyshell#25>", line 1, in <module>
fun4._doc_
AttributeError: 'function' object has no attribute '_doc_'
>>> help(fun4)
Help on function fun4 in module __main__: fun4(name)
name is a param >>> def fun5(*param)
SyntaxError: invalid syntax
>>> def fun5(*param):
print ("%d",len(param))
print (param) >>> fun5(1,2,3,4)
('%d', 4)
(1, 2, 3, 4)
>>> def fun5(*param,par):
print ("%d",len(param))
print (param) SyntaxError: invalid syntax
>>>
>>> def fun6(*param,par):函数的收集参数
print ("%d",len(param))
print (param) SyntaxError: invalid syntax
>>> def fun7(*param,name): SyntaxError: invalid syntax
>>> def fun8(*pa , name1): SyntaxError: invalid syntax
>>>

Python 2.7.10 (default, Oct 14 2015, 16:09:02) [GCC 5.2.1 20151010] on linux2Type "copyright", "credits" or "license()" for more information.>>> def function():ptintf("run")
>>> function()
Traceback (most recent call last):  File "<pyshell#3>", line 1, in <module>    function()  File "<pyshell#2>", line 2, in function    ptintf("run")NameError: global name 'ptintf' is not defined>>> def fun():print ("hello")
>>> fun()hello>>> def fun2(name):print(name)
>>> fun2(new)
Traceback (most recent call last):  File "<pyshell#11>", line 1, in <module>    fun2(new)NameError: name 'new' is not defined>>> fun2("new")new>>> >>> >>> def fun3(num1,num2):return num1+num2
>>> print (fun3(1,2))3>>> def fun4(name)SyntaxError: invalid syntax>>> def fun4(name):'name is a param'print(name)
>>> fun4("hello world")hello world>>> fun4._doc_
Traceback (most recent call last):  File "<pyshell#25>", line 1, in <module>    fun4._doc_AttributeError: 'function' object has no attribute '_doc_'>>> help(fun4)Help on function fun4 in module __main__:
fun4(name)    name is a param
>>> def fun5(*param)SyntaxError: invalid syntax>>> def fun5(*param):print ("%d",len(param))print (param)
>>> fun5(1,2,3,4)('%d', 4)(1, 2, 3, 4)>>> def fun5(*param,par):print ("%d",len(param))print (param)SyntaxError: invalid syntax>>> >>> def fun6(*param,par):print ("%d",len(param))print (param)SyntaxError: invalid syntax>>> def fun7(*param,name):SyntaxError: invalid syntax>>> def fun8(*pa , name1):SyntaxError: invalid syntax>>>

python function parameter的更多相关文章

  1. Python Function Note

    Python Function Note #汉诺塔问题Python实现 def my_move(n, a, b, c): if n == 1: print(a + ' --> ' + c) el ...

  2. kwargs - Key words arguments in python function

    This is a tutorial of how to use *args and **kwargs For defining the default value of arguments that ...

  3. python Function

    Python 2.7.10 (default, Oct 14 2015, 16:09:02) [GCC 5.2.1 20151010] on linux2 Type "copyright&q ...

  4. elike.python.function()

    将python用于基本的科学计算,能完全替代matlab.就最近写的一个物理模型程序来看,用python建立的物理模型的可控性,代码的层次性都优于matlab,只不过python没有matlab那样的 ...

  5. PyQt5 Function Parameter Declaration

    addWidget self.lcd = QLCDNumber() grid.addWidget(self.lcd,0,0,3,0) grid.setSpacing(10) void QGridLay ...

  6. python function with variadic arguments or keywords(dict) 可变参数与关键字参数

    *args 表示任意个普通参数,调用的时候自动组装为一个tuple **kwags 表示任意个字典类型参数, 调用的时候自动组装成一个dict args和kwags是两个约定俗成的用法. 变长参数可以 ...

  7. vscode主题开发

    vscode主题开发教程 https://blog.csdn.net/Suwanqing_su/article/details/105945290 个人配置结果 主题代码 到Vscode放插件的目录中 ...

  8. [python] File path and system path

    1. get files in the current directory with the assum that the directory is like this: a .py |----dat ...

  9. An Introduction to Interactive Programming in Python (Part 1) -- Week 2_2 练习

    #Practice Exercises for Logic and Conditionals # Solve each of the practice exercises below. # 1.Wri ...

随机推荐

  1. CXF 动态创建客户端调用稳定版本号为2.7.18

    今天用动态创建客户端的方式调用webservice,报了这样一个错: 2017-01-05 20:51:46,029 DEBUG main org.apache.cxf.common.logging. ...

  2. js阿拉伯数字转中文大写

    function DX(n) { if (!/^(0|[1-9]\d*)(\.\d+)?$/.test(n)) return "数据非法"; var unit = "千百 ...

  3. html与htm区别

    1.index.html与index.htm同时有,先访问.html 2.htm是为了兼容以前的DOS系统.

  4. JBPM4.4业务流程管理框架详细解读

    1. 什么是JBPM4.4业务流程管理框架? JBPM,全称是JavaBusiness Process Management(业务流程管理),它是覆盖了业务流程管理.工作流.服务协作等领域的一个开源的 ...

  5. Mac上更新Ruby

    因为准备在项目中使用bootstrap,在安装bootstrap过程中提示需要Ruby的版本在1.9.2以上,而目前使用的Ruby版本是Mac系统自带的1.8.7.所以需要对Ruby进行升级.这里使用 ...

  6. 【BZOJ-2669】局部极小值 状压DP + 容斥原理

    2669: [cqoi2012]局部极小值 Time Limit: 3 Sec  Memory Limit: 128 MBSubmit: 561  Solved: 293[Submit][Status ...

  7. iOS提交后申请加急审核

    链接:https://developer.apple.com/appstore/contact/appreviewteam/index.html 在i would like to里选择加急审核 然后填 ...

  8. VS2013单元测试 的安装、创建与执行

    1.要运行 vs2013单元测试 ,那么打开VS2013,选择工具-扩展和更新,搜索并安装Unit Test Generator. 如果不安装是不会出现Generate Unit Test的选项的,也 ...

  9. 个人学习记录2:ajax跨域封装

    /** * 跨域提交公用方法 * @param param 参数 * @param url 跨域的地址 * @param callFun 回调函数 callFun(data) */ function ...

  10. cinnamon桌面安装在其他目录下

    cinnamon桌面还不错,不过默认只能安装在/usr目录下 有很多脚本中写死了是/usr目录 编译时如下模块需要打补丁: 1.cinnamon中,需要执行 sed -i 's|usr/share|u ...