如何解决“IndentationError:意外缩进”

时间:2015-11-12 17:50:35

标签: python indentation

我正在运行Kali Linux并需要完成大量命令,但我正在制作一个脚本来真正加快我的速度。这是.py文件:

import os

if raw_input("Begin fake Access Point? (y/n): ")=="y":
 os.system(airmon-ng)

interface = input("Enter your Interface name: ")
 os.system(airmon-ng "interface" start)

尝试运行时遇到此错误:

  File "WNS.py", line 7
    os.system(airmon-ng "interface" start) 
    ^
IndentationError: unexpected indent

尝试在开头删除空格,但后来我得到了这个错误:

IndentationError: expected an indented block

1 个答案:

答案 0 :(得分:3)

在Python中,压痕非常重要。解释器使用它来知道如何划分指令块.os.system()调用的参数看起来也不好看。无论如何,这应该是它看起来像

import os

if raw_input("Begin fake Access Point? (y/n): ")=="y":
    os.system("airmon-ng")

interface = input("Enter your Interface name: ")
os.system("airmon-ng "+interface+" start")
相关问题