Scroll Down to See All▾
absaiterallanextanyasciibinboolbreakpointbytearraybytescallablechrclassmethodcompilecomplexdelattrdictdivmodenumerateevalexecfilterfloatformatfrozensetgetattrglobalshasattrhashhelphexidinputintisinstanceissubclassiterlenlistlocalsmapmaxmemoryviewminnextobjectoctopenordpowprintpropertyrangereprreversedroundsetsetattrslicesortedstaticmethodstrsumsupertupletypevarszip__import__clear_(dict)clear_(list)clear_(set)copy_(dict)copy_(list)copy_(set)fromkeysgetitemskeyspop_(dict)pop_(list)pop_(set)popitemsetdefaultupdatevaluescount_(tuple)count_(list)count_(str)index_(tuple)index_(list)index_(str)adddifferencedifference_updatediscardintersectionintersection_updateisdisjointissubsetissupersetremove_(set)remove_(list)symmetric_differencesymmetric_difference_updateunionupdateclosefilenoflushisattyreadreadablereadlinereadlinesseekseekabletelltruncatewritablewritewritelinesappendextendinsertreversesortcapitalizecasefoldcenterendswithexpandtabsfindformatisalnumisalphaisasciiisdecimalisdigitisidentifierislowerisnumericisprintableisspaceistitleisupperjoinljustlowerlstripmaketranspartitionreplacerfindrindexrjustrpartitionrsplitrstripsplitsplitlinesstartswithstripswapcasetitletranslateupperdirzfillFunction Details: encode
Description
Return an encoded version of the string as a bytes object.
Extended Description
The encode() method returns an encoded version of the string as a bytes object. By default, it uses UTF-8 encoding. The errors parameter specifies the error handling scheme: 'strict' (default) raises a UnicodeEncodeError for encoding errors, 'ignore' ignores errors, 'replace' replaces errors with a suitable replacement character, and 'xmlcharrefreplace' replaces with the appropriate XML character reference.
Read More about encode from Python Documentation
Function Signature
Module: builtins
Class: str
Parameters
Parameter List
- encoding: str
- errors: str
Return
Returns a bytes object representing the encoded string.
Return Type
bytes
Output
Explanation
This example demonstrates the basic usage of encode(). It encodes the string 'hello' using UTF-8 encoding.