如何获取wifi路由器i';我连接到使用python了吗?
我可以使用任何python库进行连接吗?或者有人可以告诉我如何在python中实现commandprompt中的命令。取决于操作系统如何获取wifi路由器i';我连接到使用python了吗?,python,wifi,Python,Wifi,我可以使用任何python库进行连接吗?或者有人可以告诉我如何在python中实现commandprompt中的命令。取决于操作系统 from sys import platform import subprocess if platform == 'linux' or platform == 'linux2': # linux output = subprocess.check_output('iwgetid', '-r') elif platform == 'darwin':
from sys import platform
import subprocess
if platform == 'linux' or platform == 'linux2':
# linux
output = subprocess.check_output('iwgetid', '-r')
elif platform == 'darwin':
# OS X
ps = subprocess.Popen(('/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport', '-I'), stdout=subprocess.PIPE)
output = subprocess.check_output(('awk', '/ SSID/ {print substr($0, index($0, $2))}'), stdin=ps.stdout)
elif platform == 'win32':
output = subprocess.check_output("netsh wlan show interfaces")
ps.wait()
print output
Windows和Linux都提供命令行工具来执行这些网络操作。对于Linux,请阅读关于
WPA-supplicant
的内容,在Windows上,您可以使用netsh
一旦您知道需要执行哪些命令,就可以使用子进程执行这些命令了
modulethat!谢谢!。您能告诉我如何只打印bssid吗?可能是在linux下,我们应该将参数作为数组传递,如sooutput=subprocess.check_output(['iwgetid','-r'])