[英]expected an indented block error <python>
I'm making ARM processor, but error occured at unexpected part!:( I know about using tab, but I don't know about what is wrong. please help me!!! 我正在制作ARM处理器,但是在意外的地方发生了错误!
def LDSTR():
global k
I=memory[k]/0b10000000000000000000000000%0b10
P=memory[k]/0b1000000000000000000000000%0b10
B=memory[k]/0b10000000000000000000000%0b10
W=memory[k]/0b1000000000000000000000%0b10
L=memory[k]/0b100000000000000000000%0b10
if(I==0):
if(P==0):
#add offset after transfer (example) ldr Rx,[Ry],Rz
if(B==0):
#ldr/str word (example) ldr Rx,Ry
if(W==0):
#no '!'
if(L==0):
#str Rx,[Ry],Rz
elif(L==1): >>>error occured!!
#ldr Rx,[Ry],Rz
elif(W==1):
#'!'exists (example)ldr Rx,[Ry,Rz]!
if(L==0):
#str Rx,[Ry],Rz!
elif(L==1):
#ldr Rx,[Ry],Rz!
The if-elif
block are empty. if-elif
块为空。 Python expects a sentence after the conditions. Python要求条件后有一个句子。
If you want to have an empty block you can use the keyword pass
: 如果您想要一个空块,可以使用关键字
pass
:
if (...):
pass
elif (...):
pass
Note: Comments #...
are ommited, and not considered as statements. 注意:注释
#...
被忽略,不被视为陈述。
no wonder, there's nothing between if
and elif
: 难怪
if
和elif
之间没有任何关系:
if(L==0):
elif(L==1):
this is a syntax error. 这是语法错误。
you can put a pass
in between, if you don't care about that branch: 如果您不关心该分支,则可以在两者之间进行
pass
:
if(L==0):
pass
elif(L==1):
pass
You don't have any code (just a comment) after the if statement where the error occurs. 在发生错误的if语句之后,您没有任何代码(仅是注释)。
If you add pass
wherever you don't have code (just a comment), things should start to work. 如果您在没有代码的地方添加
pass
(只是注释),那么一切应该开始起作用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.