我對Python中分號何時工作以及何時不工作感到困惑。 在Python(3.4.3)的下面的代碼生成語法錯誤:無效的語法分號應該如何與Python全局聲明一起工作
global winSeqs ; if len(winSeqs) == 0: makeWinSeqs(boardSize)
的(3.4.3)語言參考手冊第7表示:
> A simple statement is comprised within a single logical line. Several
> simple statements may occur on a single line separated by semicolons.
> The syntax for simple statements is:
>
> simple_stmt ::= expression_stmt
> | assert_stmt
> | assignment_stmt
...
> | global_stmt
> | nonlocal_stmt
我認爲這可能是一個錯誤(也許在文檔中),但肯定會很好地知道。
我不認爲'if語句是一個簡單的語句。 –