我似乎无法弄清楚这里发生了什么。当我编译我得到的不符合错误。缩进错误:unindent不匹配任何外部缩进级别
它给了我关于缩进不匹配就行了误差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建议的代码,并增加了一些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;
另外:如果有人可以指出/向我解释我的失败,那就太好了。因为我似乎无法在第二部分找到我的问题。这与第一个问题相同。
没有','在Python和缩进后'进行...:' – Julien
@ JulienBernu实际上允许在其中使用分号 – 2016-07-25 05:47:09
如果您使用的是Python 2,则可能会混合使用空格和制表符。这在Python 3中本身就是一个错误。你可能会尝试使用'-t'标志运行Python(这会使混合空白给出警告)或'-tt'(这会使其成为错误)。 – Blckknght