如何让 Python 知道用户连接到哪个 Wifi? [英] How do I get Python to know what Wifi the user is connected to?

查看:28
本文介绍了如何让 Python 知道用户连接到哪个 Wifi?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我 14 岁,请原谅我的 Python 知识.我正在尝试使用这样的 if/else 语句使这个程序仅在我在学校时(在学校的 Wifi 上)运行:

I'm 14, pardon my Python knowlege. I'm trying to make this program that will only run while I'm at school (on the school's Wifi) using an if/else statement like this:

if ontheschoolwifi:
     Keep running the program
else:
     close the program because im not at school and wont need it

我想知道如何让python知道如何获取它所连接的wifi.预先感谢您的帮助:)

I'd like to know how to let python know how to get what wifi it is connected to. Thank you, in advance, for your help :)

推荐答案

import subprocess

if "SchoolWifiName" in subprocess.check_output("netsh wlan show interfaces"):
    print "I am on school wifi!"

这篇关于如何让 Python 知道用户连接到哪个 Wifi?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆