smart_str
Return a string representing 's'. Treat bytestrings using the 'encoding' codec.
If strings_only is True, don't convert (some) non-string-like objects.
def smart_str(
s: any,
encoding: string = "utf-8",
strings_only: boolean = false,
errors: string = "strict"
) - > string
Return a string representing 's'. Treat bytestrings using the 'encoding' codec. If strings_only is True, don't convert (some) non-string-like objects.
Parameters
| Name | Type | Description |
|---|---|---|
| s | any | The object to be converted into a string representation. |
| encoding | string = "utf-8" | The codec used to decode the input if it is a bytestring. |
| strings_only | boolean = false | If True, prevents the conversion of non-string-like objects such as integers or booleans. |
| errors | string = "strict" | The error handling scheme to use for decoding errors (e.g., 'strict', 'ignore', 'replace'). |
Returns
| Type | Description |
|---|---|
string | The string representation of the input, or the original object if strings_only is enabled and the input is a non-string-like type. |