Python String decode() Method - Tutorialspoint
文章推薦指數: 80 %
Description. Python string method decode() decodes the string using the codec registered for encoding. It defaults to the default string encoding. Home CodingGround Jobs Whiteboard Tools Business Teachwithus PythonBasicTutorial Python-Home Python-Overview Python-EnvironmentSetup Python-BasicSyntax Python-VariableTypes Python-BasicOperators Python-DecisionMaking Python-Loops Python-Numbers Python-Strings Python-Lists Python-Tuples Python-Dictionary Python-Date&Time Python-Functions Python-Modules Python-FilesI/O Python-Exceptions PythonAdvancedTutorial Python-Classes/Objects Python-RegExpressions Python-CGIProgramming Python-DatabaseAccess Python-Networking Python-SendingEmail Python-Multithreading Python-XMLProcessing Python-GUIProgramming Python-FurtherExtensions PythonUsefulResources Python-QuestionsandAnswers Python-QuickGuide Python-Tools/Utilities Python-UsefulResources Python-Discussion SelectedReading UPSCIASExamsNotes Developer'sBestPractices QuestionsandAnswers EffectiveResumeWriting HRInterviewQuestions ComputerGlossary WhoisWho PythonStringdecode()Method Advertisements PreviousPage NextPage BeyondBasicProgramming-IntermediatePython MostPopular 36Lectures 3hours MohammadNauman MoreDetail PracticalMachineLearningusingPython BestSeller 91Lectures 23.5hours MANASDASGUPTA MoreDetail PracticalDataScienceusingPython 22Lectures 6hours MANASDASGUPTA MoreDetail Description Pythonstringmethoddecode()decodesthestringusingthecodecregisteredforencoding.Itdefaultstothedefaultstringencoding. Syntax Str.decode(encoding='UTF-8',errors='strict') Parameters encoding−Thisistheencodingstobeused.Foralistofallencodingschemespleasevisit:StandardEncodings. errors−Thismaybegiventosetadifferenterrorhandlingscheme.Thedefaultforerrorsis'strict',meaningthatencodingerrorsraiseaUnicodeError.Otherpossiblevaluesare'ignore','replace','xmlcharrefreplace','backslashreplace'andanyothernameregisteredviacodecs.register_error(). ReturnValue Decodedstring. Example LiveDemo #!/usr/bin/python Str="thisisstringexample....wow!!!"; Str=Str.encode('base64','strict'); print"EncodedString:"+Str print"DecodedString:"+Str.decode('base64','strict') Result EncodedString:dGhpcyBpcyBzdHJpbmcgZXhhbXBsZS4uLi53b3chISE= DecodedString:thisisstringexample....wow!!! python_strings.htm PreviousPage PrintPage NextPage Advertisements
延伸文章資訊
- 1Day27 Python 基礎- 字符轉編碼操作 - iT 邦幫忙
coding:utf-8 -*- import sys print(sys.getdefaultencoding()) # 打印出目前系統字符編碼s = '你好' s_to_unicode = ...
- 2What is the difference between encode/decode in Python?
- 3Python Strings decode() method - GeeksforGeeks
decode() is a method specified in Strings in Python 2. This method is used to convert from one en...
- 4decode - Python Reference (The Right Way) - Read the Docs
Syntax¶. str. decode([encoding[, errors]]). encoding: Optional. The desired encoding. Defaults to...
- 5Python Strings decode() method - GeeksforGeeks