IndentationError: unexpected unindent WHY?

后端 未结 4 1191
盖世英雄少女心
盖世英雄少女心 2021-01-01 09:10

IndentationError: unexpected unindent WHY???

#!/usr/bin/python
import sys
class Seq:
    def __init__(self, id, adnseq, colen):
        self.id     = id
             


        
相关标签:
4条回答
  • 2021-01-01 09:24

    It's because you have:

    def readTTable(fname):
        try:
    

    without a matching except block after the try: block. Every try must have at least one matching except.

    See the Errors and Exceptions section of the Python tutorial.

    0 讨论(0)
  • 2021-01-01 09:25

    This error could actually be in the code preceding where the error is reported. See the For example, if you have a syntax error as below, you'll get the indentation error. The syntax error is actually next to the "except" because it should contain a ":" right after it.

    try:
        #do something
    except
        print 'error/exception'
    
    
    def printError(e):
        print e
    

    If you change "except" above to "except:", the error will go away.

    Good luck.

    0 讨论(0)
  • 2021-01-01 09:31

    @MaxPython The answer above is missing ":"

    try:
       #do something
    except:
      # print 'error/exception'
    

    def printError(e): print e

    0 讨论(0)
  • 2021-01-01 09:42

    you didn't complete your try statement. You need and except in there too.

    0 讨论(0)
提交回复
热议问题