Python代码中的IndentationError

时间:2015-02-03 22:16:34

标签: python python-2.7

我有这段代码看起来缩进但无法运行。我收到以下错误:

File "./cloneRepos.py", line 16
    for line in f:
     ^
IndentationError: expected an indented block

代码如下:

def cloneRepos(dirPath,reposListFile):
    with open(reposListFile,'r') as f:
        for line in f:
            s=line.split(".git")    #Splits based on .git into two halves

            x=s[0].split("/")       #Splits the string based on that character

            repoName=x[-1]          #Gets the last element in the array

            repo = clone_repository(line, dirPath) # Clones a non-bare repository line is repoUrl and dirPath is repository path

            print repoName

            print line

1 个答案:

答案 0 :(得分:0)

我使用了两个标签而不是一个,然后就可以了!遵循w.r.t python缩进的最佳做法是什么?我们应该使用制表符还是空格?我是python的新手!