-1
subprocess.call (cmd, shell = True)을 사용할 때이 print 문의 끝 부분에 매달려있는 0을 어떻게 중지합니까?Subprocess.call이 반환 코드를 인쇄하지 못하게하는 방법은 무엇입니까?
print("The top five memory consumers on the system are:")
print(subprocess.call('ps -eo pid,ppid,cmd,%mem,%cpu --sort=-%mem | head -n 6', shell=True))
출력 :
The top five memory consumers on the system are:
PID PPID CMD %MEM %CPU
807 1 /usr/bin/python -Es /usr/sb 3.1 0.0
615 555 /sbin/dhclient -d -q -sf /u 3.0 0.0
1500 917 python 1.7 0.0
9921 917 python ./dkap_sysinfo.py 1.7 0.0
556 1 /usr/sbin/rsyslogd -n 1.3 0.0
0
^문제 아이는
음 - 인쇄물을 꺼내십시오. 당신은 그것을하는 사람입니다. 그러지 마. 'print (subprocess.call (...))'을'subprocess.call (...)'로 대체하십시오. –