Micropython strings

2019-09-07 02:44发布

问题:

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 ???

回答1:

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