<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.21.0/tensorflow/python/util/compat.py#L111-L127) |

Acts as an alias for the `as_text` function..

#### View aliases


**Compat aliases for migration**

See
[Migration guide](https://www.tensorflow.org/guide/migrate) for
more details.

[`tf.compat.v1.compat.as_str`](https://www.tensorflow.org/api_docs/python/tf/compat/as_str)

<br />

    tf.compat.as_str(
        bytes_or_text, encoding='utf-8'
    )

<br />

<br />

<br />

| ## Args ||
|---|---|
| `bytes_or_text` | The input value to be converted. A bytes or unicode object. |
| `encoding` | Optional string. The encoding to use if bytes_or_text is a bytes object. Defaults to 'utf-8'. |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| A unicode string. ||

<br />

<br />

<br />

<br />

| ## Raises ||
|---|---|
| `TypeError` | If bytes_or_text is not a bytes or unicode object. |
| `UnicodeDecodeError` | If bytes_or_text is a bytes object and cannot be decoded using the specified encoding. |

<br />