Erratic encoding of byte to string on Python 3 on Ubuntu

前端 未结 1 1853
囚心锁ツ
囚心锁ツ 2021-01-27 11:23

I\'m new to Python and am working on a sensor. I\'m building my code line by line and I have trouble with the encoding/decoding part for bytes to string. Same code, sometime it

1条回答
  •  深忆病人
    2021-01-27 12:05

    This may have have happened because your string had a non ascii character. When you ran your code again there was no non ascii character in the string and hence it ran successfully.

    You can encode the non ascii characters by using encode() function

    0 讨论(0)
提交回复
热议问题