python function parameter
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的更多相关文章
- Python Function Note
Python Function Note #汉诺塔问题Python实现 def my_move(n, a, b, c): if n == 1: print(a + ' --> ' + c) el ...
- 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 ...
- python Function
Python 2.7.10 (default, Oct 14 2015, 16:09:02) [GCC 5.2.1 20151010] on linux2 Type "copyright&q ...
- elike.python.function()
将python用于基本的科学计算,能完全替代matlab.就最近写的一个物理模型程序来看,用python建立的物理模型的可控性,代码的层次性都优于matlab,只不过python没有matlab那样的 ...
- PyQt5 Function Parameter Declaration
addWidget self.lcd = QLCDNumber() grid.addWidget(self.lcd,0,0,3,0) grid.setSpacing(10) void QGridLay ...
- python function with variadic arguments or keywords(dict) 可变参数与关键字参数
*args 表示任意个普通参数,调用的时候自动组装为一个tuple **kwags 表示任意个字典类型参数, 调用的时候自动组装成一个dict args和kwags是两个约定俗成的用法. 变长参数可以 ...
- vscode主题开发
vscode主题开发教程 https://blog.csdn.net/Suwanqing_su/article/details/105945290 个人配置结果 主题代码 到Vscode放插件的目录中 ...
- [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 ...
- 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 ...
随机推荐
- Xcode8与iOS10那些事
一.证书管理 用Xcode8打开工程后,比较明显的就是下图了,这个是苹果的新特性,可以帮助我们自动管理证书.建议大家勾选这个Automatically manage signing(Ps.但是在bea ...
- rpc框架之avro 学习 1 - hello world
avro是hadoop的一个子项目,提供的功能与thrift.Protocol Buffer类似,都支持二进制高效序列化,也自带RPC机制,但是avro使用起来更简单,无需象thrift那样生成目标语 ...
- 如何理解vue.js组件的作用域是独立的
vue.js组件的作用域是独立,可以从以下三个方面理解: 1.父组件模板在父组件作用域内编译,父组件模板的数据用父组件内data数据:2.子组件模板在子组件作用域内编译,子组件模板的数据用子组件内da ...
- jprofiler_监控远程linux服务器的tomcat进程(实践)
一.软件列表: windows和linux的jprofiler的版本必须一致 1.jprofiler_linux_9_1_1.tar.gz 2.jprofiler_windows_x64 9_1_1 ...
- asp.net mvc4使用NPOI 数据处理之快速导出Excel文档
一.背景 在之前做的小项目里有一需求是:要求将一活动录入的数据进行统计,并以excel表格形式导出来,并且对表格格式要求并不高. 二.问题分析 鉴于用户只要求最终将数据库中的数据导出excel,对于格 ...
- 国内优秀npm镜像推荐及使用
npm全称Node Package Manager,是node.js的模块依赖管理工具.由于npm的源在国外,所以国内用户使用起来各种不方便.下面整理出了一部分国内优秀的npm镜像资源,国内用户可以选 ...
- HTML5学习总结-番外05 响应式布局
1. 响应式布局 响应式布局是2015年5月份提出的一个概念,简而言之,就是一个网站能够兼容多个终端,而不是为每个终端做一个特定的版本.这个概念是为解决移动互联网浏览而诞生的.其目的是为用户提欧共更加 ...
- photoshop拾色器如何恢复默认?
今天在做设计图的时候,遇到一个问题,当时就把我给整蒙了. 问题是这样的,ps的调色器变成了这样,如下: 本来应该是这样: 可能有人已经看出两张图的不同之处了. 但是我当时忙的不得了,恩是不知道哪里除了 ...
- Oracle表格建立
Oracle学习第一天:学习了如何在网页上建立表空间,以及在关联性表格上建立表格,填充表格,学习了如何建立自己的表空间.效果如下:
- web前端历史的总结
1.早期的前后一体,前端和后端是一个整体. 2.早期的后端mvc概念,前端只是后端mvc里面的视图层 (laravel就是mvc) 3.ajax技术改变了一切 2004年 Gmail 2005Goog ...