0

Using Micropython sockets I received a message which contained the following string:

b'xxx/yyy'

I don't know how the "b" got there, or what it is !!!

I can also enter this using an input statement

    x = input('Enter:')
>>> b'xxx/yyy'
    print(x)
>>> b'xxx/yyy'
    print (len(x))
>>> 7
    L = []
    L = x.split('/')
>>> TypeError: can't convert 'str' object to str implicitly

There must be a simple explanation to this, but I can not see it.

Is this some new type of variable ???

3

2 Answers 2

3

It states that it is a utf-8 decoded string enclosed in a bytearray!!

Sign up to request clarification or add additional context in comments.

Comments

1

You need to convert this value. So instead of:

print(x)

try

print(x.decode('utf-8'))

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.