2015-11-12 76 views
0

好吧,对于像我这样没有经验的人来说,这可能是你们最讨厌的问题。但是裸露在一起,我很抱歉。Python错误 - 缩进

我运行卡利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

你有一个空间在该行的乞讨,你需要排队与上面的线。 – Will

+0

是的,我这样做,然后我得到这个错误:“IndentationError:预期一个缩进块” – iZodiac

+0

但只能删除它之前的第二个,而不是第一个,因为这是一个是在“if”块(即完全由错误信息)。 – agold

回答

3

Indendation在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") 
+0

好是这工作,但你说我使用os.system()不好看?我应该如何分类? – iZodiac

+0

4个空格缩进。 ':'后面的任何内容应该是四行(或一个制表符),从上面的行缩进 – Busturdust

+1

@Busturdust:Python将制表符展开到下一个第8位。新代码应该避免使用制表符。 –