[英]How to find out Windows network interface name in Python?
Windows命令netsh interface show interface
显示所有网络连接及其名称。 名称可以是Wireless Network Connection
, Local Area Network
或Ethernet
等。
我想使用Python脚本更改netsh interface ip set address "Wireless Network Connection" static 192.168.1.3 255.255.255.0 192.168.1.1 1
的IP地址,但是我需要一个网络接口名称。
是否有可能具有此信息,就像我们可以使用socket.gethostname()
获得主机名一样? 或者我可以通过其他方式用Python更改IP地址?
我不知道Python netsh
API。 但是,使用一对子subprocess
调用并不难。 首先发出netsh interface show interface
,解析您返回的输出,然后发出set address
命令。
还是我错过了重点?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.