Jun-11-2018, 11:28 PM
Use check_output.
It will return output as a whole bytes object so can decode(to string) and split at
Example untested:
It will return output as a whole bytes object so can decode(to string) and split at
'/r/n'
to get lines.Example untested:
from subprocess import check_output command = check_output(["gphoto2", "--get-config", "/main/capturesettings/shutterspeed"]) output = command.decode().strip() sspeed = output.split('\r\n')[2] with open('sspeed.txt') as f_out: f_out.write(sspeed)