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

时间:2016-07-25 05:32:33

标签: python indentation

我似乎无法弄清楚这里发生了什么。当我编译时,我得到不匹配错误。

它给出了有关$result=unserialize("your serialized array which is in db");

行上缩进不匹配的错误
bgB = 0;

所以在用@Downshift建议更新代码并添加一些elifs之后我得到了同样的东西 def calcBG(ftemp): "This calculates the color value for the background" variance = ftemp - justRight; # Calculate the variance adj = calcColorAdj(variance); # Scale it to 8 bit int bgList = [0,0,0] # initialize the color array if(variance < 0): bgR = 0; # too cold, no red bgB = adj; # green and blue slide equally with adj bgG = 255 - adj; elif(variance == 0): # perfect, all on green bgR = 0; bgB = 0; bgG = 255; elif(variance > 0): # too hot - no blue bgB = 0; bgR = adj; # red and green slide equally with Adj bgG = 255 - adj;

另外:如果有人可以向我指出/向我解释我未能做到的事情,那将是伟大的。因为我似乎无法在第二部分找到我的问题。这与第一个问题相同。

1 个答案:

答案 0 :(得分:0)

由于口译员告诉你压痕水平不一致。确保在第一行方法定义和if语句后缩进,除了修改缩进之外没有对代码进行任何更改:

def calcBG(ftemp):
    """This calculates the color value for the background"""
    variance = ftemp - justRight;   # Calculate the variance
    adj = calcColorAdj(variance);   # Scale it to 8 bit int
    bgList = [0,0,0]                # initialize the color array
    if(variance < 0):         
        bgR = 0;                    # too cold, no red         bgB = adj;                  # green and blue slide equally with adj         bgG = 255 - adj;     elif(variance == 0):            # perfect, all on green         bgR = 0;         bgB = 0;         bgG = 255;     elif(variance > 0):             # too hot - no blue
        bgB = 0;
        bgR = adj;                  # red and green slide equally with Adj
        bgG = 255 - adj;