2011-07-16 20 views
-2

我使用python的在線控制檯:http://shell.appspot.com/ 我試圖寫這樣的代碼:當我寫下第一行class tree:我按回車的Python:在網上控制檯蟒蛇錯誤

class tree: 
def __init__(self, charge, left=None, right=None): 
    self.charge = charge 
    self.left = left 
    self.right = right 

我得到這個控制檯出錯

Traceback (most recent call last): 
File "/base/data/home/apps/shell/1.335852500710379686/shell.py", line 221, in get 
compiled = compile(statement, '<string>', 'single') 
File "<string>", line 2 
^ 
IndentationError: expected an indented block 

有沒有人可以告訴我如何寫這段代碼? 謝謝。

+1

Downvoted的問題不顯示任何研究工作,此外,堆棧溢出完全是錯誤的地方問這種事情。超級用戶充其量是最好的去處。 –

回答

4

請勿使用ENTER。
截至在線殼頁面使用的底部表明:(!指令是直接在其下方)

按住Shift鍵並輸入新行

0

您必須將整個班級輸入到該應用程序的文本框中。我知道它與通常的Python shell不同。 :)

粘貼在您的代碼;它會工作。

0

您需要一次輸入班級的所有內容。要轉到新線路,請使用Shift+Enter。例如,這對我有用 -

class tree:  # press Shift+Enter here 
    print 'aas' # press Enter when you are done 
0

從這裏複製並粘貼回來。你可能在某個地方有一個錯誤的空間,但是如果從這裏複製,它就可以工作。