1
subprocess.popen으로 작업하려고하는데 잘 작동합니다. 유일한 문제는 "ifconfig"대신 "iffconfig"대신 "iffconfig"를 입력하면 전체 스크립트가 다운되는 것입니다. 잘못된 명령에서 충돌이 발생하지 않도록하려면 어떻게해야합니까? 대신 오류 메시지로 답장하십시오. 그냥 올바른 방향으로 나를 가리 키십시오. 예제 코드 :잘못된 Popen 명령에서 파이썬 스크립트를 충돌시키지 않으려면 어떻게합니까?
command = "ifconfig" #this command is actually requested so you can make a typo which causes it to crash
temp = subprocess.Popen(command, stdout=subprocess.PIPE)
out = temp.stdout.read()
out.replace("\r", "\n")
outlist = out.split("\n")
for line in outlist:
print(line)
덕분에 어떤 도움 : 파이썬 문서의 Handling Exceptions 페이지에서
감사합니다. 나는 그것을 볼 것이다 :) – Jurze
아무 문제가 형제! – DeathCamel57