How to edit string from STDOUT
<p>I have this code:</p>

<pre><code>netshcmd = subprocess.Popen('netsh wlan stop hostednetwork', shell=True, stderr=subprocess.PIPE, stdout=subprocess.PIPE)
output, errors = netshcmd.communicate()
if errors:
    print("Warrning: ", errors)
else:
    print("Success", output)
</code></pre>

<p>and output is this: </p>

<pre><code>Success b'The hosted network stopped. \r\n\r\n'
</code></pre>

<p>How to get output like this "Success The hosted network stopped."?</p>

<p>That is a bytestring. Change your code to make that a str:</p>

<pre><code>netshcmd = subprocess.Popen('netsh wlan stop hostednetwork', shell=True, stderr=subprocess.PIPE, stdout=subprocess.PIPE)
output, errors = netshcmd.communicate()
if errors:
    print("Warrning: ", errors.decode())
else:
    print("Success", output.decode())
</code></pre>

python subprocess netsh