遇到的錯(cuò)誤信息
一、IndentationError:expected an indented block
Eclipse中,執(zhí)行也需要注意縮進(jìn)。
第一次執(zhí)行時(shí)赊级,未對(duì)print進(jìn)行縮進(jìn),報(bào)錯(cuò):IndentationError:expected an indented block岔绸。
一句話(huà) 有冒號(hào)的下一行往往要縮進(jìn)理逊,該縮進(jìn)就縮進(jìn)
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')已經(jīng)沒(méi)有意義了盒揉,
因?yàn)閜ython3 使用unicode了挡鞍,不用再設(shè)utf-8了
三、Jython Error: SyntaxError: inconsistent dedent at line 12 column 4
錯(cuò)誤原因:縮進(jìn) 空格
python最具特色的就是使用縮進(jìn)來(lái)表示代碼塊预烙,不需要使用大括號(hào)({})墨微。
縮進(jìn)的空格數(shù)是可變的,但是同一個(gè)代碼塊的語(yǔ)句必須包含相同的縮進(jìn)空格數(shù)扁掸。
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報(bào)ImportError: No module named 'StringIO'參考網(wǎng)址:http://www.cnblogs.com/testyao/p/5658200.html
修改配置文件