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 decode()方法 - 極客書
decode()方法使用注冊編碼的編解碼器的字符串進行解碼。它默認為默認的字符串編碼。 語法以下是decode()方法的語法: str . decode ( encoding = UTF-8 ,...
- 2Python String encode() decode() - DigitalOcean
Python bytes decode() function is used to convert bytes to string object. Both these functions al...
- 3Decode UTF-8 in Python | Delft Stack
- 4python的decode()与encode()详解 - CSDN博客
1.decode()bytes.decode(encoding=“utf-8”, errors=“strict”)1.这个函数是bytes类型数据调用的,字符串str类型是不能够调用的。
- 5codecs — Codec registry and base classes — Python 3.10.7 ...
This module defines base classes for standard Python codecs (encoders and decoders) and ... Custo...