首先为pycharm配置管理员权限

image.png
修改网卡名字为英文字符

image.png
python+netsh控制网卡
import os
# 修改静态ip
static = os.popen('netsh interface ipv4 set address "kc" static 192.168.0.166 255.255.255.0')
# 禁用网卡
diable = os.popen('netsh interface set interface "kc" admin=DISABLE')
# 启用网卡
enable = os.popen('netsh interface set interface "kc" admin=ENABLE')
# 修改动态ip
dynamic = os.popen('netsh interface ipv4 set address "kc" dhcp')