Indentation Error: unindent does not match any outer indentation level
Indentation Error: unindent does not match any outer indentation level
我似乎无法弄清楚这里发生了什么。编译时出现 不匹配 错误。
它给我关于 bgB = 0;
行的缩进不匹配的错误
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;
所以在使用@Downshift 建议更新代码并添加一些 elif 后,我得到了同样的结果
def calcBG(ftemp):
"This calculates the color value for the background"
方差 = ftemp - 恰到好处; # 计算方差
adj = calcColorAdj(方差); # 将其缩放为 8 位 int
bgList = [0,0,0] # 初始化颜色数组
如果(方差 < 0):<br>
bgR = 0; # 太冷了,没有红色<br>
bgB = 形容词; # 绿色和蓝色用 adj<br> 平均滑动
bgG = 255 - 调整;<br>
elif(variance == 0): # 完美,全部为绿色<br>
bgR = 0;<br>
bgB = 0;<br>
bgG = 255;<br>
elif(variance > 0): # 太热了 - 没有蓝色
bgB = 0;
bgR = 形容词; # 红色和绿色用 Adj 均匀滑动
bgG = 255 - 调整;
此外:如果有人可以 out/explain 指出我在这方面失败的确切原因,那就太好了。因为我似乎无法在第二部分中找到我的问题。这与第一个问题相同。
正如解释器告诉您的那样,您的缩进级别不一致。请务必在第一行方法定义和 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;
我似乎无法弄清楚这里发生了什么。编译时出现 不匹配 错误。
它给我关于 bgB = 0;
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;
所以在使用@Downshift 建议更新代码并添加一些 elif 后,我得到了同样的结果
def calcBG(ftemp):
"This calculates the color value for the background"
方差 = ftemp - 恰到好处; # 计算方差
adj = calcColorAdj(方差); # 将其缩放为 8 位 int
bgList = [0,0,0] # 初始化颜色数组
如果(方差 < 0):<br>
bgR = 0; # 太冷了,没有红色<br>
bgB = 形容词; # 绿色和蓝色用 adj<br> 平均滑动
bgG = 255 - 调整;<br>
elif(variance == 0): # 完美,全部为绿色<br>
bgR = 0;<br>
bgB = 0;<br>
bgG = 255;<br>
elif(variance > 0): # 太热了 - 没有蓝色
bgB = 0;
bgR = 形容词; # 红色和绿色用 Adj 均匀滑动
bgG = 255 - 调整;
此外:如果有人可以 out/explain 指出我在这方面失败的确切原因,那就太好了。因为我似乎无法在第二部分中找到我的问题。这与第一个问题相同。
正如解释器告诉您的那样,您的缩进级别不一致。请务必在第一行方法定义和 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;