Python Decode() Function Syntax

Syntax: decode(encoding, error)
Parameters:

  • encoding : Specifies the encoding on the basis of which decoding has to be performed. 
  • error : Decides how to handle the errors if they occur, e.g ‘strict’ raises Unicode error in case of exception and ‘ignore’ ignores the errors occurred. 
  • Returns : Returns the original string from the encoded string.

Python Strings decode() method

In Python we have decode() is a method specified in Strings. This method is used to convert from one encoding scheme, in which the argument string is encoded to the desired encoding scheme. This works opposite to the encode. It accepts the encoding of the encoding string to decode it and returns the original string.

Similar Reads

Python Decode() Function Syntax

Syntax: decode(encoding, error) Parameters: encoding : Specifies the encoding on the basis of which decoding has to be performed.  error : Decides how to handle the errors if they occur, e.g ‘strict’ raises Unicode error in case of exception and ‘ignore’ ignores the errors occurred.  Returns : Returns the original string from the encoded string....

Encode and Decode a String in Python

The above code is an example of encoding and decoding. Here first we encoded the string using UTF-8 and then decoded it which gives the same output String as we give it in input....

Contact Us