【Python-03】練習03-20170714
遇到的錯誤資訊
一、IndentationError:expected an indented block
Eclipse中,執行也需要注意縮排。
第一次執行時,未對print進行縮排,報錯:IndentationError:expected an indented block。
一句話 有冒號的下一行往往要縮排,該縮排就縮排
How to deal with IndentationError:
- Make sure your lines are indented properly, remembering that Python thinks that tab stops are every 8 columns. 2) Look for a missing colon on the line above, which is usually a for, if, else, while, try, or similar type of line. In general, if a line ends in a colon, the next line with code needs to be indented by some amount. – Mike DeSimone Oct 13 '10 at 4:03
二、
但sys.setdefaultencoding('utf-8')已經沒有意義了,
因為python3 使用unicode了,不用再設utf-8了
三、Jython Error: SyntaxError: inconsistent dedent at line 12 column 4
錯誤原因:縮排 空格
python最具特色的就是使用縮排來表示程式碼塊,不需要使用大括號({})。
縮排的空格數是可變的,但是同一個程式碼塊的語句必須包含相同的縮排空格數。
Solution: Delete the extra space, and remember that if you want to use tabs it is best to set your editor if it is possible to use spaces for tab characters, this will save you many late nights debugging tab based indentation vs space based indentation in your jython scripts.
Another reason why it is important to use spaces and not tabs is because as you copy code fom AIX/Linux shells to Windows ie between different text editors they IDE/editing tools. The may disagree on tab width, and if you have mixed tab and spaces during your typing/pasting, you can get a miss match of indentations.
Keep to spaces and use 2 or 4, then you are going to be fine!
四、python3中用HTMLTestRunner.py報ImportError: No module named 'StringIO'參考網址:http://www.cnblogs.com/testyao/p/5658200.html
修改配置檔案
相關文章
- 新手練習:Python練習題目Python
- MYSQL練習1: DQL查詢練習MySql
- sql 練習SQL
- MySQ練習
- MySQL練習MySql
- latex練習
- ddl練習
- U7-11課綜合練習+12課階段測評練習——複習練習題目
- Scala學習(三)練習
- Scala學習(四)練習
- Scala學習(五)練習
- Scala學習(六)練習
- Scala學習(七)練習
- nginx配置練習Nginx
- python練習Python
- mysql練習題MySql
- Java方法練習Java
- MYSQL練習二MySql
- JS原生練習JS
- TypeScript 練習題TypeScript
- C++練習C++
- java練習題Java
- pl/sql練習SQL
- 入門練習
- Find命令練習
- pl/sql 練習SQL
- SQL 練習題SQL
- 課後練習
- 【THM】The Marketplace練習
- 課堂練習
- openGauss練習
- 隨堂練習
- SQL練習題SQL
- 【THM】dogcat練習GC
- 選單練習
- 【CSS練習】IT修真院–練習2-開發工具CSS
- python 練習0000Python
- 演算法練習演算法