Как написать сценарий в Windows, который выполняет следующую команду?
autoflake -i -r --remove-all-unused-imports %file_directory%
Мой скрипт выглядит так:
file_directory = input("Enter directory name to run autoflake: ")
def autoflake_run():
try:
# I would like to run the command here.
except:
print("Path file error. Please make sure directory exists.")
autoflake_run()
Используйте модуль subprocess
.
import subprocess
file_directory = input('Enter directory name to run autoflake: ')
def autoflake_run():
try:
subprocess.run('autoflake -i -r --remove-all-unused-imports {}'
.format(file_directory))
except:
print('Path file error. Please make sure directory exists.')
autoflake_run()