반환 된 하위 프로세스의 일부를 인쇄하는 방법은 무엇입니까? 예 : 아래 예제에서 "기능 수"와 "술어 수"만 인쇄하려면 어떻게해야합니까?하위 프로세스의 출력 부분을 인쇄하는 방법
for line in p.stdout:
if "Number of" in line:
print line
그것은 데이터 만입니다, 당신은 당신이 원하는 (또는 필요) 비트를 선택해야합니다 : 내가 볼 수
command = "java -cp \"C:\mallet-2.0.7\class;C:\mallet-2.0.7\lib\mallet-deps.jar\" cc.mallet.fst.SimpleTagger --train true --model-file model train
p = Popen(command, stdout=PIPE, stderr=STDOUT, shell = True)
for line in p.stdout:
print line
>>>
Number of features in training data: 6
Number of predicates: 6
Labels: O noun non-noun
Preparing O
O->O(O) O,O
.........
이것은 서브 프로세스와는 아무런 관련이 없습니다. 출력을 파싱하고 (필요한 경우) 필요한 것을 얻습니다. –
'command = "'또는'command ="''또는'command = "" "'를'''에서 벗어날 필요가 없도록 변경하는 것이 좋습니다. – sotapme