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()
输出结果
执行以上代码后,将产生以下结果-
Traceback (most recent call last): File "test.py", line 11, in <module> printme(); TypeError: printme() takes exactly 1 argument (0 given)
热门推荐
10 祝女儿简短祝福语大全
11 大学新年祝福语简短创意
12 元旦适合的祝福语简短
13 朋友出远门祝福语简短
14 初六简短的祝福语
15 祝男孩生日祝福语简短
16 同事调离的祝福语简短
17 拜年红包的祝福语简短
18 妈妈生日祝福语简短励志