在Python中调用函数
定义函数只会为其命名,指定要包含在函数中的参数,并构成代码块。
一旦确定了函数的基本结构,即可通过从另一个函数或直接从Python提示符处调用它来执行它。以下是调用printme()函数的示例-
#!/usr/bin/python
# Function definition is here
def printme( str ):
"This prints a passed string into this function"
print str
return;
# Now you can call printme function
printme("I'm first call to user defined function!")
printme("Again second call to the same function")输出结果
执行以上代码后,将产生以下结果-
I'm first call to user defined function! Again second call to the same function
热门推荐
10 六一祝贺文案祝福语简短
11 送病人简短的祝福语
12 孩子新年祝福语简短精辟
13 简短元旦祝福语古言
14 牛年企业祝福语简短大气
15 冬泳祝福语简短8字
16 女儿出阁的祝福语简短
17 祝福语签名简短霸气女生
18 文案生日祝福语高级简短