Reputation: 15
I m calling an executable in a python script which gives an output in the terminal as follows:
Number of Iterations: 150
Average time per step is 0.306834 ms
Average time for collisions is 0.027553 ms
Average time for velocity updates is 0.109900 ms
Average time for position updates is 0.031053 ms
Total loop time is 46.2161 ms
But i want to store this text in a variable so that i can edit it. How to do this???
Upvotes: 0
Views: 219
Reputation: 9894
Use subprocess. It lets you redirect the output. You could simply do:
output = subprocess.check_output(args)
Upvotes: 1