Python-IP地址模块

时间:2018-01-22 20:24:12

标签: python

我安装了python 2.7。我安装了pip install py2-ipaddress。在powershell中进行以下操作。问题是No Output

import ipaddress
def ipEntered():
    while True:
        try:
            val = input("Please enter the ip address of the server you wish to connect with:")
            return ipaddress.ip_address(val)
        except ValueError:
            print("Not a valid IP address")

1 个答案:

答案 0 :(得分:1)


程序运行正常。你能分享它失败的例子吗?我使用以下代码来测试它。

import ipaddress
def ipEntered():
        while True:
                try:
                        val = raw_input()
                        return ipaddress.ip_address(val)
                except ValueError:
                        print ("Invalid")

print ipEntered()
相关问题