在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 老哥出门祝福语简短语
16 送灯祝福语简短独特
17 幼儿狗年祝福语大全简短
18 好听的元旦简短祝福语