import socket;
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
result = sock.connect_ex(('127.0.0.1',8899))
if result == 0:
print("被占用")
else:
print("没有被暂用")
版权声明:本文为nbbscdd原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
import socket;
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
result = sock.connect_ex(('127.0.0.1',8899))
if result == 0:
print("被占用")
else:
print("没有被暂用")