What does encoding mean in python?

(*-*)浩
Release: 2019-07-03 14:34:37
Original
22513 people have browsed it

encoding means encoding. In python, the Unicode type is the basic type of encoding.

What does encoding mean in python?

#The Python encode() method encodes a string in the encoding format specified by encoding. The errors parameter can specify different error handling schemes.

encode() method syntax:(Recommended learning:Python video tutorial)

str.encode(encoding='UTF-8',errors='strict')
Copy after login

Parameters

encoding -- The encoding to use, such as "UTF-8".

errors --Set different error handling options. The default is 'strict', which means encoding errors cause a UnicodeError. Other possible values are 'ignore', 'replace', 'xmlcharrefreplace', 'backslashreplace' and any value registered via codecs.register_error().

Return value

This method returns the encoded string.

The following examples show examples of the encode() method:

#!/usr/bin/python str = "this is string example....wow!!!"; print "Encoded String: " + str.encode('base64','strict')
Copy after login

The output results of the above examples are as follows:

Encoded String: dGhpcyBpcyBzdHJpbmcgZXhhbXBsZS4uLi53b3chISE=
Copy after login

More Python related technical articles, Please visit thePython Tutorialcolumn to learn!

The above is the detailed content of What does encoding mean in python?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!