How do I pass variable when using Python subprocess module

后端 未结 2 1700
鱼传尺愫
鱼传尺愫 2020-12-12 03:58

I\'m trying to use python Subprocess module to enable/disable Ethernet connection from python code. Below is my code in which the first step is looking for the available \"E

2条回答
  •  旧时难觅i
    2020-12-12 04:59

    Use string formatting, interpolation, or concatenation:

    x = 'Ethernet10'
    subprocess.call('netsh interface set interface ' + x + ' ENABLED')
    

提交回复
热议问题