17.1k views
0 votes
When reading data across the network (i.e. from a URL) in Python 3, what string method must be used to convert it to the internal format used by strings?

User Kierans
by
4.4k points

1 Answer

0 votes

Answer:

decode( )

Step-by-step explanation:

We can use the method decode( ) to decode the string using the codec registered for encoding.

There are two parameters

encoding: We can encode with this parameter.

errors: If used to manage the errors.

For example:

String = "this is string example....wow!!!";

String = Str.encode('base64','strict');

If we print these variables we have:

String = b'dGhpcyBpcyBzdHJpbmcgZXhhbXBsZS4uLi53b3chISE='

String = this is string example....wow!!!

User Mechanic Sekar
by
3.8k points