How to read and write unicode (UTF-8) files in Python?

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

How to read and write unicode (UTF-8) files in Python? - The io module is now recommended and is compatible with Python 3's open syntax: The ... Home CodingGround Jobs Whiteboard Tools Business Teachwithus TrendingCategories DataStructure Networking RDBMS OperatingSystem Java iOS HTML CSS Android Python CProgramming C++ C# MongoDB MySQL Javascript PHP SelectedReading UPSCIASExamsNotes Developer'sBestPractices QuestionsandAnswers EffectiveResumeWriting HRInterviewQuestions ComputerGlossary WhoisWho Howtoreadandwriteunicode(UTF-8)filesinPython? PythonServerSideProgrammingProgramming BeyondBasicProgramming-IntermediatePython MostPopular 36Lectures 3hours MohammadNauman MoreDetail PracticalMachineLearningusingPython BestSeller 91Lectures 23.5hours MANASDASGUPTA MoreDetail PracticalDataScienceusingPython 22Lectures 6hours MANASDASGUPTA MoreDetail TheiomoduleisnowrecommendedandiscompatiblewithPython3'sopensyntax:Thefollowingcodeisusedtoreadandwritetounicode(UTF-8)filesinPythonExampleimportio withio.open(filename,'r',encoding='utf8')asf:   text=f.read() #processUnicodetext withio.open(filename,'w',encoding='utf8')asf:   f.write(text) RajendraDharmkar Updatedon20-Feb-202007:59:19 RelatedQuestions&AnswersConvertUnicodetoUTF-8inJava ConvertUTF-8toUnicodeinJava HowtorepresentUnicodestringsasUTF-8encodedstringsusingTensorflowandPython? HowmanybitsareusedtorepresentUnicode,ASCII,UTF-16,andUTF-8charactersinjava? ReadandwriteWAVfilesusingPython(wave) ReadandwritetararchivefilesusingPython(tarfile) ReadandwriteAIFFandAIFCfilesusingPython(aifc) UTF-8ValidationinC++ HowtoconvertanMySQLdatabasecharactersetandcollationtoUTF-8? HowtoReadandWritesFilesinRuby ConvertStringtoUTF-8bytesinJava ConvertASCIITOUTF-8EncodinginPHP? HowtoconvertwronglyencodeddatatoUTF-8inMySQL? HowtoreadtextfilesusingLINECACHEinPython HowtoreadandparseCSVfilesinC++? PreviousPage PrintPage NextPage  Advertisements



請為這篇文章評分?