title: Python subprocess.Popen result stored in a variable
body: <p>I've seen various other posts about this, but unfortunately I still haven't been able to figure this out:</p>
  
  <p>If I do something like this:</p>
  
  <pre><code>temp = subprocess.Popen("whoami", shell=True, stdout=subprocess.PIPE)
  out = temp.communicate()
  print(out)
  </code></pre>
  
  <p>then I get something of the form</p>
  
  <pre><code>(b'username\n', None)
  </code></pre>
  
  <p>With other attempts (such as adding a .wait()) I've been getting the username on one line, and a 0 as a return code on the next, however only the 0 was being stored in my variable.</p>
  
  <p>Is there an easy way I can format that to store only the username in a variable?  I tried something like out[3:11] but that didn't work.</p>
  
  <p>Thanks</p>