How to convert between bytes and strings in Python 3?

后端 未结 4 1839
囚心锁ツ
囚心锁ツ 2020-11-28 04:25

This is a Python 101 type question, but it had me baffled for a while when I tried to use a package that seemed to convert my string input into bytes.

As you will s

4条回答
  •  醉话见心
    2020-11-28 05:12

    TRY THIS:

    StringVariable=ByteVariable.decode('UTF-8','ignore')
    

    TO TEST TYPE:

    print(type(StringVariable))
    

    Here 'StringVariable' represented as a string. 'ByteVariable' represent as Byte. Its not relevent to question Variables..

提交回复
热议问题