亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

Chinaunix

標(biāo)題: python環(huán)境運行異常 [打印本頁]

作者: linux_xue    時間: 2012-07-18 09:17
標(biāo)題: python環(huán)境運行異常
代碼:
def foo():
    "this is a doc string."
    return true

在命令行環(huán)境第二行完成后,就報錯:

root@bogon:/opt# python
Python 2.6.6 (r266:84292, Dec 27 2010, 00:02:40)
[GCC 4.4.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> def foo():
... "this is a doc string."  File "<stdin>", line 2
    "this is a doc string."
                          ^
IndentationError: expected an indented block
>>>

在ipython環(huán)境下輸入完全正確。

請明白原由的朋友給個指導(dǎo),謝謝!
作者: anonymous0502    時間: 2012-07-18 09:24
需要有縮進(jìn)
作者: linux_xue    時間: 2012-07-18 09:30
謝謝!這個問題不是縮進(jìn)的問題,您可以在linux命令行環(huán)境測試下。
作者: anonymous0502    時間: 2012-07-18 09:38
測試了,是縮進(jìn)問題:
  1. [root@fruit ~]# python
  2. Python 2.6.6 (r266:84292, Jun 18 2012, 14:10:23)
  3. [GCC 4.4.6 20110731 (Red Hat 4.4.6-3)] on linux2
  4. Type "help", "copyright", "credits" or "license" for more information.
  5. >>> def foo():
  6. ... "this is a doc string."
  7.   File "<stdin>", line 2
  8.     "this is a doc string."
  9.                           ^
  10. IndentationError: expected an indented block
  11. >>> def foo():
  12. ...     "this is a doc string."
  13. ...     return true
  14. ...
  15. >>>
復(fù)制代碼

作者: linux_xue    時間: 2012-07-18 09:47
奧,明白了。謝謝!
命令行也要保持縮進(jìn),非常感謝!




歡迎光臨 Chinaunix (http://72891.cn/) Powered by Discuz! X3.2