반응형
Notice
Link
목록자바 (21)
스택큐힙리스트
프로그램을 실행하거나 시스템 명령을 호출하는 방법은 무엇인가요?
파이썬에서 쉘 또는 명령 프롬프트에 입력한 것처럼 외부 명령어를 호출하는 방법은 무엇인가요?답변 1표준 라이브러리의 subprocess 모듈을 사용하세요. import subprocess# for simple commandssubprocess.run([ls, -l]) # for complex commands, with many args, use string + `shell=True`:cmd_str = ls -l /tmp | awk '{print $3,$9}' | grep rootsubprocess.run(cmd_str, shell=True)subprocess.run의 장점은 #$$$$&!#@$&보다 더 유연하다는 것입니다 (당신은 stdout, stderr, real status code, 더 나은 er..
카테고리 없음
2023. 3. 19. 21:43