串口助手 Serial Port Utility
Eclipse Java编程工具(仅供学习)
OpenCV 4.12.0 出现cv2 error错误
错误代码如下:
cv2.error: OpenCV(4.12.0) D:aopencv-pythonopencv-pythonopencvmoduleshighguisrcwindow.cpp:1301: error: (-2:Unspecified error) The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Cocoa support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script in function 'cvShowImage'
原因:
OpenCV 4.12.0 默认关闭了cv2的一些函数,两种办法 一种是修改配置。另外一种换成4.11版本
以下是卸载旧的扩展安装新的版本
pip uninstall opencv-python
pip uninstall opencv-contrib-python
安装opencv4.11
pip install -i https://mirrors.aliyun.com/pypi/simple/ opencv-python==4.11.0.86
pip install -i https://mirrors.aliyun.com/pypi/simple/ opencv-contrib-python==4.11.0.86 screen avi cam_屏幕录像工具 (仅供学习使用 请勿商用)
python 判断某IP是否ping通 成功则返回1 失败返回0
利用ping命令的返回信息差异,以及re正则采集的策略 计算是否ping通

代码如下
import subprocess
import re
def ping_server(server_ip):
try:
output = subprocess.check_output(['ping', '-i', '4', server_ip])
#return output.decode('ansi')
result =output.decode('ansi')
#return result
match =re.findall(r'Average = \d',result)
if match:
return 1
else:
return 0
except subprocess.CalledProcessError as e:
#return e.output.decode('ansi')
return 0
server_ip = '192.168.0.17'
result = ping_server(server_ip)
print(result)
python 检测IP ping检测 查物理地址
import subprocess
import re
import socket
from scapy.all import sr1, IP, ICMP
def get_mac_address(ip):
try:
# 执行arp命令来查找IP对应的MAC地址
result = subprocess.run(['arp', '-a'], capture_output=True, text=True, check=True)
output = result.stdout
# 解析输出,注意Windows上的输出格式可能与Linux不同
match = re.search(rf'{ip}\s+([0-9a-fA-F-]+)', output)
if match:
return match.group(1)
else:
return None
except subprocess.CalledProcessError as e:
print(f"Error: {e}")
return None
def ping(host):
# 创建一个ICMP请求数据包
packet = IP(dst=host)/ICMP()
# 发送数据包并接收响应
reply = sr1(packet, timeout=1, verbose=False)
# 检查是否收到回复
if reply is not None and reply.haslayer(ICMP):
return True
else:
return False
ip_address = "192.168.0.254"
mac_address = get_mac_address(ip_address)
print(f"MAC Address: {mac_address}")
print(f"IP: {ip_address}")
if ping(ip_address):
print(f"{ip_address} is active.")
else:
print(f"{ip_address} is die.")