encode()
Encode a string to bytes.
Usage
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.
Example
encode(“hello”) b’hello’