Python
- 8 ответов
- 0 вопросов
10
Вклад в тег
import subprocess
# Run the program and capture its output
process = subprocess.Popen(['program', 'arg1', 'arg2'], stdout=subprocess.PIPE)
# Read the output of the program in real-time
while True:
output = process.stdout.readline()
if output == b'' and process.poll() is not None:
break
if output:
print(output.strip())
# Print the return code of the program
print(process.returncode)
from operator import attrgetter
sorted(items, key=attrgetter('name'))