python2 vs python3

Jagga Soorma jagga13 at gmail.com
Fri Oct 18 14:27:57 EDT 2019


Hello,

I am writing my second python script and got it to work using
python2.x.  However, realized that I should be using python3 and it
seems to fail with the following message:

--
Traceback (most recent call last):
  File "test_script.py", line 29, in <module>
    test_cmd = ("diskcmd -u " + x + " | grep -v '\*' | awk '{print $1,
$3, $4, $9, $10}'" )
TypeError: Can't convert 'bytes' object to str implicitly
--

I then run this command and save the output like this:

--
test_info = (subprocess.check_output( test_cmd,
stderr=subprocess.STDOUT, shell=True )).splitlines()
--

Looks like the command output is in bytes and I can't simply wrap that
around str().  Thanks in advance for your help with this.



More information about the Python-list mailing list