0
>>> x=5
>>> y=10
>>> if(x>y):
... print 'x is greater':
File "<stdin>", line 2
print 'x is greater':
^
IndentationError: expected an indented block
>>> x=5
>>> y=10
>>> if(x>y):
... print 'x is greater':
File "<stdin>", line 2
print 'x is greater':
^
IndentationError: expected an indented block
錯誤消息說明了這一切。 Python使用縮進來處理塊,因爲你的print
說法應該是if
的塊中,應縮進:
>>> x=5
>>> y=10
>>> if(x>y):
... print 'x is greater': # Note the indentation here
的錯誤信息是很清楚的...... – jonrsharpe
u能請編輯代碼? –
https://docs.python.org/2/tutorial/ – jonrsharpe