Dec-15-2018, 11:37 AM
Received data a for
Example:
check_output()
will be bytes,so need to decode()
to string.Example:
>>> s = b'Quality is good' >>> if s.startswith('Quality'): ... print('True') ... Traceback (most recent call last): File "<interactive input>", line 1, in <module> TypeError: startswith first arg must be bytes or a tuple of bytes, not str >>> # Fix >>> s = s.decode() #same as s.decode('utf-8') >>> if s.startswith('Quality'): ... print('True') ... True