프로그램을 닫으려고합니다.이 경우에는 눈에 띄지 만 의미 론적 실수는 계속하고 있습니다.파이썬을 사용하여 외부 프로그램이나 창을 종료하는 방법
sup_programs.txt
{
'spotify': ['C:/Users/Daniiar/AppData/Roaming/Spotify/Spotify.exe']
}
스크립트 : 내가 죽()와 종료를 (사용
class Path(object):
import ast
sup_programs_txt = open('sup_programs.txt', 'r')
s_p = sup_programs_txt.read()
paths = ast.literal_eval(s_p)
sup_programs_txt.close()
paths = Path().paths
program_name = 'spotify'
def open_program(path_name):
import subprocess
subprocess.Popen(path_name)
open_program(paths[program_name])
def close_program(path_name):
import subprocess
p = subprocess.Popen(path_name)
p.terminate()
yes = input(" ... ")
if 'close' in yes or 'yes' in yes:
close_program(paths[program_name])
else:
print('too bad')
) 둘 중 근무하지 않은 및 os.system을 ('에서 taskkill'여기 내 코드입니다) 다른 방법이 있습니까? 아니면 기존 방법을 잘못 사용하고 있습니까?
현재, Windows 10 및 Python 3.5를 사용하고 있습니다. 귀하의 도움에 감사드립니다
어떤 추적을 받고 있습니까? – n1c9
의미 론적 실수? –
왜 새 프로세스를 시작하고 죽이면 이미 실행중인 다른 프로세스를 죽일 수 있습니까? –