PYTHON ERROR:IndentationError:unindent与任何外部缩进级别都不匹配

Sha*_*ers 2 python

运行这段代码时:

#timestamp, capture, and tweet an image
def stamp_cap_tweet():    
    timestamp = time.strftime("%d%m%Y-%H%M%S")
    os.system("fswebcam -r 960x720 -d /dev/video0 " + timestamp + ".jpg") #save image to disk
    twit.update_status_with_media(timestamp + ".jpg", status = "@shahidrogers " + timestamp) #tweet image @username
    print "Tweeted image at " + timestamp #make a record in the Python output
Run Code Online (Sandbox Code Playgroud)

我收到了错误

文件"tweetpicture.py",第17行

os.system("fswebcam -r 960x720 -d /dev/video0 " + timestamp + ".jpg")                                                  
                                                                    ^                                                   IndentationError:
Run Code Online (Sandbox Code Playgroud)

unindent与任何外部缩进级别都不匹配

这可能意味着什么?我已经四处搜索,人们已经说过有标签和空格的混合,但我完全不理解这一点,因为我还是Python的新手,这是我的前几行编码.

谢谢!

Nic*_*tti 6

在Python代码中,每个缩进级别必须包含完全相同的空格序列和每个缩进到该级别的行的制表符.

实现此目的的最佳和最简单的方法是仅为每个缩进级别使用空格,始终使用相同的数字.建议的数字是四.

可以将许多编辑器配置为使用给定数量的空格替换选项卡.