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 ...
随机推荐
- jQuery中的width() innerWidth() outerWidth() outerWidth(true)的区别
width()仅仅包括content(内容) innerWidth()包括content(内容)和padding(补白) outerWidth()包括content(内容),padding(补白)和b ...
- android第一行代码-9.内容提供器
内容提供器(Content Provider)主要用于在不同的应用程序之间实现数据共享的功能, 内容提供器包括两部分:使用现有的内容提供器来读取和操作相应程序中的数据跟创建自己的内容提供器给我们程序的 ...
- mac os 下搭建android开发环境
mac os 下搭建android开发环境 周银辉 mac os 下搭建android环境比较方便, 如下几个步骤: 1,安装jdk 先搞清楚自己是否已经安装,在命令行下:java -version, ...
- Log4j简单学习笔记
log4j结构图: 结构图展现出了log4j的主结构.logger:表示记录器,即数据来源:appender:输出源,即输出方式(如:控制台.文件...)layout:输出布局 Logger机滤器:常 ...
- JS组件系列——基于Bootstrap Ace模板的菜单和Tab页效果分享(你值得拥有)
前言:最近园子里多了许多谈语言.谈环境.谈逼格(格局)的文章,看看笑笑过后,殊不知其实都是然并卵.提升自己的技术才是王道.之前博主分享过多篇bootstrap组件的文章,引起了很多园友的关注和支持,看 ...
- asp.net mvc ajax 异步刷新例子
这几天在asp.net中使用ajax来做异步刷新,这里整理一下 1.首先看前台页面点击的时候调用函数 function shuxin() { $.ajax( { url: "GetValue ...
- python爬某个网站的图片
# _*_ coding: gbk _*_ import urllib import urllib2 import re class Spider: def getImage(self,html): ...
- Linux操作系统中,*.zip、*.tar、*.tar.gz、*.tar.bz2、*.tar.xz、*.jar、*.7z等格式的压缩与解压
zip格式 压缩: zip -r [目标文件名].zip [原文件/目录名] 解压: unzip [原文件名].zip 注:-r参数代表递归 tar格式(该格式仅仅打包,不压缩) 打包:tar -cv ...
- 关于GeoWebCache的部署说明
最近因为工作需要学习了GeoWebCache,有了一些实战经验跟大家分享一下. 废话不多说,直接上问题! 1.切片的缓存问题 当地图服务(这里默认指WMS)的数据更新时,GeoWebCache的切片如 ...
- u盘安装系统教程详解
一.准备阶段 提前准备一个至少1G或以上的u盘,方便好用. 1.制作u盘启动工具 (1)工具下载,推荐IT天空的优启通 下载地址:https://www.itiankong.net/thread-37 ...