2016-07-25 24 views
-4

ここで何が起こっているのか分かりません。私がコンパイルすると、が一致しません。エラー。インデントエラー:インデントが外側のインデントレベルと一致しません

それはとても@Downshiftが提案するもので、コードを更新すると私は同じこと 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;

を得た少数のelifsを追加した後、私に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; 

とライン上のインデントの不一致に関するエラーを与えますALSO:もし誰かが私に指摘してくれれば、私はそれがうまくいくとは思えません。この2番目の部分で私の問題を見つけることができないからです。これは最初の問題と同じ問題です。

+2

なし ';' pythonで、インデントの後に 'デフ...:' – Julien

+0

を@ JulienBernu実際にそこにセミコロンを使用することが許可されています –

+1

Python 2を使用している場合、スペースとタブを混在させているかもしれません。これはPython 3ですべてエラーになります。Pythonを '-t'フラグ(混在した空白に警告を出す)または' -tt'(これはエラーになります)で実行しようとするかもしれません。 – Blckknght

答えて

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; 
関連する問題