為什么運行不了啊。。。也注意縮進了啊。。
>>>?def?greet(name='world'): ...?????print?'Hello,'?+?name?+?'.' ...?greet('Bart') ??File?"<stdin>",?line?3 greet() greet('Bart') ????????^ SyntaxError:?invalid?syntax
>>>?def?greet(name='world'): ...?????print?'Hello,'?+?name?+?'.' ...?greet('Bart') ??File?"<stdin>",?line?3 greet() greet('Bart') ????????^ SyntaxError:?invalid?syntax
2016-04-26
舉報
2016-04-26
在 Python Shell 和 Python IDLE 中, 如果一個代碼塊(如 if, elif, else, for, while, def, class, try, with 等等)寫完了,如果想跳出代碼塊寫其他的代碼,比如上面的這個 函數定義完,想調用函數時, 一定要 多敲一個空行,直到“>>> ”這個符號出現,再寫。如下:
2016-04-26
不要用+號 用逗號
2016-04-26
...?????print?'Hello,'?+?name?+?'.' 回車后要再加一個回車,
greet('Bart')這句前要再回車下.