decode - Python Reference (The Right Way) - Read the Docs

文章推薦指數: 80 %
投票人數:10人

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"",line1,in UnicodeDecodeError:'ascii'codeccan'tdecodebyte0xc5inposition0:ordinalnotinrange(128) >>>'źdźbło'.decode('ascii','ignore') u'dbo' >>>'źdźbło'.decode('ascii','replace') u'\ufffd\ufffdd\ufffd\ufffdb\ufffd\ufffdo' SeeAlso¶ encode() ReadtheDocs v:latest Versions latest Downloads pdf htmlzip epub OnReadtheDocs ProjectHome Builds FreedocumenthostingprovidedbyReadtheDocs.



請為這篇文章評分?