Im使用以下子过程调用c = subprocess.Popen("wmic nic where 'netconnectionid like '%οπικ%' and PhysicalAdapter=True' get netconnectionid",stdout=subprocess.PIPE)。我想做的就是传递netconnectionid(又名网络适配器名称),这样我就可以将其传递给变量并在此处使用它]
[ip = self.ip_list.currentText() subprocess.Popen('netsh interface ipv4 set address name="' + sk + '"
static 192.168.131.' + ip + ' 255.255.255.0 192.168.131.1')
我这样做是因为适配器名称在不同的pc中不同。问题在这里:
os = c.stdout.read()
sk = os.splitlines()[2].strip().decode('cp437')
结果是'Τοπικήσύνδεση'。我正在尝试将字节转换为希腊字母。我已经尝试过utf-8,但它不起作用。我尝试使用.decode('cp437')打印sk变量,并且它是唯一可以正确执行的解码选项,但是之后,netsh命令仍然无法正常工作。我尝试使用英文字母重命名适配器并使用utf-8解码,效果很好。这就是我基本上要转换的内容:b'\xe7?\xe3??? \xe5??\xeb\xee\xe5?'
关于如何进行这项工作的任何想法?