Better way to strip leading character, new line, cr from QBytearray

365 views Asked by At

If I only convert the QBytearray to str then the output looks like this: b'Enter an input A,B,C:\r\n'

I can get rid of the \r\n by using QBytearray.simplified() then the output looks like this :b'Enter an input A,B,C:'

In order to remove the last b' ' I have to only print string[2:-1] output:Enter an input A,B,C:

These seems like a long way to go about it: simplified,convert to string,strip array. Is there a better method? Currently the data is coming from a Qprocess and being appending to a textBrowser.

s = self.process.readAll()
s = s.simplified()
self.itpBrowser.append(str(s)[2:-1])
1

There are 1 answers

2
eyllanesc On BEST ANSWER

Use bytearray({your QBytearray}).decode()