Python dapatkan output perintah ke variabel

import subprocess as sp
output = sp.getoutput('whoami --version')
print (output)
Breakable Baboon