我安装了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")
答案 0 :(得分:1)
程序运行正常。你能分享它失败的例子吗?我使用以下代码来测试它。
import ipaddress
def ipEntered():
while True:
try:
val = raw_input()
return ipaddress.ip_address(val)
except ValueError:
print ("Invalid")
print ipEntered()