to_text

paddle.compat. to_text ( obj, encoding='utf-8', inplace=False ) [source]

All string in PaddlePaddle should be represented as a literal string.

This function will convert object to a literal string without any encoding. Especially, if the object type is a list or set container, we will iterate all items in the object and convert them to literal string.

In Python3:

Decode the bytes type object to str type with specific encoding

In Python2:

Decode the str type object to unicode type with specific encoding

Parameters
  • obj (unicode|str|bytes|list|set) – The object to be decoded.

  • encoding (str) – The encoding format to decode a string

  • inplace (bool) – If we change the original object or we create a new one

Returns

Decoded result of obj

Examples

import paddle

data = "paddlepaddle"
data = paddle.compat.to_text(data)
# paddlepaddle