我一直在寻找一种使用脚本打开和关闭 wifi 的方法。我认为这可以通过进入飞行模式或其他方法来完成。当我在谷歌上搜索答案时,我找不到任何对 Windows 有用的东西,只找到 Android 甚至 macOS 的东西。
有人有 2 个功能吗,一是关闭 wifi,一是重新打开 wifi?或者与特定的连接/断开连接也可以。如果相关的话,这是我的默认wifi。
Python 无法直接访问您的 Wifi 适配器,但 Windows 可以。
所以你可以使用os
模块来运行命令提示符代码并控制您的 WiFi 适配器。
获取接口名称
-
然后您可以使用该名称来运行开/关命令
# Get the interface name using this script.
import os
os.system("netsh interface show interface")
然后将其替换为Wifi
在这个脚本中开始。
import os
def enable():
os.system("netsh interface set interface 'Wifi' enabled")
def disable():
os.system("netsh interface set interface 'Wifi' disabled")
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)