Jan-30-2019, 06:12 PM
(Jan-30-2019, 05:33 PM)buran Wrote: if using 3.6+ use f-strings
subprocess.run(['netsh', 'interface', 'set', 'interface', 'name="Wi-Fi"', f'newname="{changeName}"'])if using lower version
subprocess.run(['netsh', 'interface', 'set', 'interface', 'name="Wi-Fi"', 'newname="{}"'.format(changeName)])for greater readability you may want to make this before the call
import subprocess change_name = input("Enter the Interface name:") new_name = 'newname="{}"'.format(change_name) # new_name = f'newname="{change_name}"' subprocess.run(['netsh', 'interface', 'set', 'interface', 'name="Wi-Fi"', new_name]) subprocess.run(['netsh', 'interface', 'show', 'interface'])Perfect Thanks Buran.
don't useos.system
- it's depreciated, usesubprocess.call
or even bettersubprocess.run