简体   繁体   English

尝试调用函数时Python IDLE中的语法错误

[英]Syntax error in Python IDLE when trying to call a function

I am learning Python code. 我正在学习Python代码。 When I create a function it works fine but when I go to call the function I get a syntax error, what is wrong with my code? 当我创建一个函数它工作正常,但当我去调用该函数时,我得到一个语法错误,我的代码有什么问题?

    >>> def someFunction(a,b):
            print (a+b)
       someFunction(12,451)
    SyntaxError: invalid syntax

You need to hit enter one more time after your print statement, it thinks your function call was part of the function definition. 你需要在print语句后再输入一次,它认为你的函数调用是函数定义的一部分。 You'll know when you completed the function definition when it prompts you for a new statement with 当您提示输入新语句时,您将知道何时完成了函数定义

>>>

So it would look like 看起来就像

>>> def someFunction(a,b):
        print (a+b)

>>> someFunction(12,451)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM