Python错误 - IndentationError:意外缩进

时间:2015-07-19 09:43:53

标签: python

看起来第二个条件中有缩进错误。有些请看看,让我知道需要更正...

IP = raw_input("Enter the Ip Address \n")
IPAddress= IP.split('.')


if (len(IPAddress) == 4):
    print " It is a valid IP address "
x1,x2,x3,x4 = IP.split('.')

        if(int(x1) == 192 and (0 <= int(x2) and int(x2) <= 255) and (0 <= int(x3) <= 255) and (0 <= int(x4) <= 255)) or (int(x1) == 172 and (16 <= int(x2) <= 31) and (0 <= int(x3) <= 255) and (0 <= int(x4) <= 255)) or (int(x1) == 10 and (0 <= int(x2) <= 255) and (0 <= int(x3) <= 255)and (0 <= int(x4) <= 255)):
            print IP + " is a private IP address"
        else:
            print IP + " is a public IP address"
else:
    print IP " is invalid "

1 个答案:

答案 0 :(得分:2)

我已经将你的代码复制粘贴到一个名为wing ide的程序中,并且它直接告诉我你的缩进,如果声明和其他的关闭。

使用这样的程序来帮助你轻松犯错误