How to fix IndentationError: “expected an indented block”?

后端 未结 2 1802
南方客
南方客 2021-01-29 09:50

I get an error

IndentationError: expected an indented block

in line line 3

answer = subprocess.check_output([\'/home/dir/         


        
2条回答
  •  礼貌的吻别
    2021-01-29 10:08

    Python requires indentation to indicate code that is conditional under for loops, while loops, if and else statements, etc. Generally, this is code that runs contingent on logic before a colon.

    Most coders use four spaces for indentation.

    Tabs are a bad idea because they may create different amount if spacing in different editors. They're also potentially confusing if you mix tabbed indentation with spaced indentation. If you're using an IDE like Eclipse or Eric, you can configure how many spaces the IDE will insert when you press tab.

    I think your code should be:

    import subprocess 
    
    while True: 
        answer = subprocess.check_output(['/home/dir/final/3.sh']) 
    final = int(answer) // int('1048576')
    print final
    

提交回复
热议问题