## encode()


Encode a string to bytes.


Usage


``` python
encode(
    data,
    encoding="utf-8",
)
```


## Parameters


`data: str`  
The string to encode.

`encoding: str = ``"utf-8"`  
The character encoding to use.


## Returns


`bytes`  
The encoded bytes.


## Examples

``` python
    >>> encode("hello")
```

    b'hello'


## See Also

[decode()](decode.md#gdtest_src_google_seealso.decode)
