Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/329.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何获取wifi路由器i';我连接到使用python了吗?_Python_Wifi - Fatal编程技术网

如何获取wifi路由器i';我连接到使用python了吗?

如何获取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':

我可以使用任何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':
    # 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下,我们应该将参数作为数组传递,如so
output=subprocess.check_output(['iwgetid','-r'])