python检测远程端口是否打开的方法
Jun 06, 2016 am 11:22 AM本文实例讲述了python判断远程端口是否打开的方法。分享给大家供大家参考。具体实现方法如下:
import socket sk = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sk.settimeout(1) try: sk.connect(('www.sharejs.com',80)) print 'Server port 80 OK!' except Exception: print 'Server port 80 not connect!' sk.close()
希望本文所述对大家的Python程序设计有所帮助。

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

How to set font size on mobile phone (easily adjust font size on mobile phone)

What are the advantages and disadvantages of templating?

MIT's latest masterpiece: using GPT-3.5 to solve the problem of time series anomaly detection

Google AI announces Gemini 1.5 Pro and Gemma 2 for developers

How to choose a mobile phone screen protector to protect your mobile phone screen (several key points and tips for purchasing mobile phone screen protectors)

Improved detection algorithm: for target detection in high-resolution optical remote sensing images
