我可以使用任何python库连接,或者有人可以告诉我如何在python中实现commandprompt的命令。
答案 0 :(得分:1)
取决于操作系统。
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