用户输入端口号或者服务名 获得端口号
PORT = input('>>>')
try:
port = int(PORT)
except ValueError:
try:
port = socket.getservbyname(PORT,'tcp')
except socket.error as err_msg:
print (PORT + ' : ' + err_msg)
print(port)
用户输入端口号或者服务名 获得端口号
PORT = input('>>>')
try:
port = int(PORT)
except ValueError:
try:
port = socket.getservbyname(PORT,'tcp')
except socket.error as err_msg:
print (PORT + ' : ' + err_msg)
print(port)