decode - Python Reference (The Right Way) - Read the Docs
文章推薦指數: 80 %
Syntax¶. str. decode([encoding[, errors]]). encoding: Optional. The desired encoding. Defaults to the default string encoding. See codecs module for a full ...
PythonReference(TheRightWay)
latest
Introduction
Definitions
CodingGuidelines
FundamentalDataTypes
Built-InFunctions
ComprehensionsandGeneratorExpression
ContainerDataAccess
Operators
Statements
OtherObjects
DoubleUnderscoreMethodsandVariables
Exceptions
Constants
Boilerplate
GlimpseofthePSL
Resources
Licence
PythonReference(TheRightWay)
Docs»
decode
EditonGitHub
decode¶
Description¶
Decodesthestringusingthecodecregisteredforencoding.
Syntax¶
str.decode([encoding[,errors]])
encoding
Optional.Thedesiredencoding.Defaultstothedefaultstringencoding.Seecodecsmoduleforafulllist.
errors
Optional.errorsmaybegiventosetadifferenterrorhandlingscheme.
Typicalerrorsvalues:
‘strict’
RaiseValueError(orasubclass);thisisthedefault.
‘ignore’
Ignorethecharacterandcontinuewiththenext.
‘replace’
Replacewithasuitablereplacementcharacter
Otherpossiblevaluesareanyothernameregisteredviacodecs.register_error(),seesectionCodecBaseClasses.
ReturnValue¶
unicode
TimeComplexity¶
#TODO
Example¶
>>>'źdźbło'.decode('windows-1250')#polishwordmeaningabladeofgrass
u'\u0139\u015fd\u0139\u015fb\u0139\u201ao'
>>>'źdźbło'.decode('ascii','strict')
Traceback(mostrecentcalllast):
File"
延伸文章資訊
- 1Python String decode() Method - Tutorialspoint
Description. Python string method decode() decodes the string using the codec registered for enco...
- 2Day27 Python 基礎- 字符轉編碼操作 - iT 邦幫忙
coding:utf-8 -*- import sys print(sys.getdefaultencoding()) # 打印出目前系統字符編碼s = '你好' s_to_unicode = ...
- 3What is the difference between encode/decode in Python?
- 4codecs — Codec registry and base classes — Python 3.10.7 ...
This module defines base classes for standard Python codecs (encoders and decoders) and ... Custo...
- 5decode - Python Reference (The Right Way) - Read the Docs
Syntax¶. str. decode([encoding[, errors]]). encoding: Optional. The desired encoding. Defaults to...