报错信息
binascii.Error: Invalid base64-encoded string: number of data characters (7121) cannot be 1 more than a multiple of 4
产生过程
base64Test.py
import base64
# Base64编码的字符串
b64_str = "\u0000tf/\u0000w\u0000EAAYEBQYFBAYGBQYHBwYIChAKCgkJChQODwwQFxQYGBcUFhYaHSUfGhsjHBYWICwgIyYnKSopGR8tMC0oMCUoKSgBBwcHCggKEwoKEygaFhooKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoK\u00007AABEIA\u0000cAmwMBIgACEQEDEQD/\u0000ACiAAABBQEBAQEBAQAAAAAAAAAAAQIDBAUGBwgJCgsQAAIBAwMCBAMFBQQEAAABfQECAwAEEQUSITFBBhNRYQcicRQydJChCCNC\u0000MEVUdDwJDNicYIJChYXGBkaJSYnKCkqNDU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6doOFiYaIsImSlpOVaZaYyJmiiqOlmaaoeKmy\u0000rO1\u0000ba4\u0000LnC\u0000sPF\u0000cbI\u0000MnS\u0000tPV\u0000dbY\u0000NnhUeLk\u0000OXn\u0000\u0000jq\u0000PHz\u0000\u0000T2\u0000vf5\u0000gEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoLEQACAQIEBAMEBwUEBAABAncAAQIDEQQFITEGEkFRB2FxEyIydQgUQZCh\u0000MEJIzNS\u0000BVicdEKFiQ0USTxFxgZGiYnKCkqNTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXmCdoOFiYaIsImSlpOVaZaYyJmiiqOlmaaoeKmy\u0000rO1\u0000ba4\u0000LnC\u0000sPF\u0000cbI\u0000MnS\u0000tPV\u0000dbY\u0000NniUuPl\u0000ebo\u0000Ony\u0000vP1\u0000fb4\u0000Pn/\u0000gAMAwEAAhEDEQA/A\u0000aF\u0000\u0000XV\u0000vqiyiQnJRgcdS\u0000XHqJ4XheK\u0000\u0000r3Uc3EZuvNKSqc\u0000wAWTz9K\u0000MzMC\u0000st\u0000jRB\u0000CgACdY0\u0000pdi\u0000r4Ubmu3\u0000VKdIJMlUkcn\u0000wuaTzA3cVC5\u0000NRSGIV3UMsWfzHRDJujis\u0000Ff0FV\u0000L2xajX5\u0000N9EO\u0000OL\u0000M\u00006\u0000q2MLmj+W\u0000VpcDf2\u0000lb/AU6IZ\u0000WT\u0000rJ0P0NZOZDr\u0000\u0000QfSfQ5bWKZCceBdPSuf1LRAasYUyg/itBU\u0000SW1KUfz\u0000RtJ\u0000\u0000LWTaP2lVzIT\u0000dvPnug\u0000t4gHk6x\u0000a5/GuqkObHZLlsg\u0000EP1\u0000nljVG4sdbEoMuhqa\u0000A6TAelck4C\u0000xlz\u0000QvXH\u0000FmR\u0000tmdPFfs\u0000r+YjCi\u0000glrG\u0000b+O0w6\u0000b1yUEqtX\u0000\u0000u\u0000\u00005YHvbIFJ8v\u0000iyl\u0000\u0000iKeC\u0000MZJ5YWVce\u0000UnxTxz4\u0000edSTkh0\u00002t7EsHsO1vj\u0000mpsSOp6\u0000o4t\u0000DcNQsR3UkoGf\u0000Fy\u0000\u00006h\u0000nJ/sXpN\u0000pMkNpGT\u0000ek5\u0000udeH\u0000IxbMPk\u0000iatKcvd\u0000QB7\u0000ZjifQH5df3u\u0000kXgBwAT\u0000UneW3gkGuBY\u0000fZl\u0000K6aR\u0000zGGwRXaOEvGNzppUk8pyy5PzJni\u0000WgD2aNFXhQBxyWaHiD\u0000Egeiba8IWTh\u0000xHp\u0000TyV\u0000POSYy8aFFx/Uqbe\u0000qLwVYoLFotSaI7xNNMuPwTAieI4IjJGcgjv\u0000ZebFG07cjqRXZMPiPR0\u0000\u00003NakA7\u0000XMh\u0000w\u0000ZecHoel7KV0\u0000z\u0000DozKG7mK\u0000oD\u0000OWS\u0000V9r\u0000RI3eWANRudbfs7UfvbY\u00002y3\u0000I4fyh0q\u0000jJ4\u0000SJRUvkv\u0000wA+E\u00008A\u0000wtF\u0000BvMlviffuX6\u00001\u00009ixIADx2VW\u0000jHWa3P\u00002Qa\u0000kezeWQMNyipVmcD\u0000Gsi\u0000mK3\u0000Vjz\u00000mmBYx3WDhhVZHhGr1ieJzp\u0000ydKQzdV\u0000owc\u0000ofODXE+IPEE\u0000mnBBJosazKT\u0000o7cUNPVpTJ7\u0000y7P\u0000\u0000qWSQ9lbCGPi\u0000P1A2NS\u0000xJs\u0000QGq\u0000ySHQGm2d3pt\u00000yr\u0000\u0000e/\u0000A5w\u0000fep\u0000XUTKfukMeatYnxIySx8IqfqeTOwT20e\u0000XhbYxL9\u0000\u0000RUSjoJTl7x\u0000saDVbxtE0mT\u0000Q3Z\u0000k3AU3qP\u0000V4LdeO5\u0000WrfTmSZ\u0000GYk\u0000Mj6\u0000jTAJLNc\u0000dNBbEFJU0WBeCqDUCI1Ua1b\u0000gfNViGlsqUCPTLhRo0m\u0000\u0000W4iwJLWX5WTj9M\u0000tEv\u0000QDZdIdFbIRkP\u0000dBSPwCyffe\u0000kyOHzgr\u0000Xrndu6F\u0000w\u0000HbKWVy\u00005IL\u0000zJ\u0000YCep\u000049\u0000Q8x\u0000LZR\u0000qM7\u0000n70GaEvpjT3lGuPTo09BAvf\u0000KsB\u0000lAG\u0000RNvmnim\u0000MwEDEmf\u0000t\u0000i\u0000G8fGHeApHyyK\u0000b7Ncif\u0000FJ/\u0000lqv\u0000w\u0000QSH7gPH7hWCnR\u0000wVQ\u0000k9BGZX+V\u00008AL\u00008A\u0000wqv\u0000vHfUUSA\u0000Ur7\u00000ioD\u0000gDN\u0000V8TFagXMt2\u0000IJq\u0000HnOVsCrCf8AL1oA\u0000OZSGSmhfmhpM\u0000PRYDBulK38YyjJIht1XHoSa1iE\u0000c8N\u0000GxERHv4\u0000\u0000v9EXv9W1O4P\u0000FxHn2C\u0000j0+\u0000\u0000lZpqUJAX4YaRFWJ\u0000lHXFab\u0000dBaaGjgsWxhTBkl\u0000U1kUHgqDz7MVc23Ues7Spis\u0000\u0000k+\u0000XkeUN1yY0LpTYPXa\u0000xRslCg\u0000TOs\u0000mWfJ\u00005xpZ7O\u0000qgW\u0000OYSHAuf\u0000ajL\u0000M1LIxLBeU81\u0000\u0000kSIQOucUgJJaPaKAMUiD\u0000KenFFFAEyHjivmX9m\u0000y03VP\u0000em\u0000bW\u0000\u0000zPb3CFEa3ti\u0000Ti\u0000mYG\u0000Nr2dPEcThzS\u0000VfFptnM\u0000gkG\u0000TWAB37WdD2BisK6VFvHm\u0000jo\u0000b9nQv0q\u0000FZQQbeOOGMesRBf\u0000CqFTuIWmM6TmVggPTvGdiLyIai3p3TW\u0000YPTiz1ylRYj\u00002NA\u000001SQNoklo9AaNk/\u0000tJf\u0000buh\u0000FziOTj+\u0000lfHmH\u0000G\u0000vspm\u00008Ai\u0000rEPvQaav39\u0000v8A\u0000FAAGzUi\u0000imsJyWsH\u0000G7lUL3p\u0000O+cAoqypy4\u0000TCkHHNUMeCb\u0000pp5cFRkdAis\u0000\u0000MkYahN\u0000DLqEtqgGxMCywND\u0000yzyXT5J\u00003\u0000nyYriDbX2Olx2Gnr/A\u0000deTyxtP\u0000H3aYLD\u0000xkk\u0000IVycSFuO3auUcZ/\u0000K8VXV6SXgt2MUSeiFAF\u0000S9JM\u0000QQIj\u0000NM\u0000vOcc57\u00001vf\u0000RqHTmg0\u0000F6VA\u0000MfWfQWasldU\u0000Dx\u0000XDeJdLk\u0000Sqo\u0000UZZiThk\u0000UAOfxnG\u0000cWU\u0000NPxeoUpKykYKnBqGbis\u0000n9oT\u0000hy\u0000nIB\u0000j21R3atcjMp\u0000iiiylrSyr6KCCOiitxz\u0000ZVy\u0000xQC\u0000\u0000EU\u0000M\u0000rXcjw\u0000fgma\u0000ZbAZVd\u0000E\u0000n\u000039a\u0000e0u\u0000VP5\u0000EbKCMCviL4R\u0000App\u0000D\u00006TOzU\u0000cHtd0OpGbKUHRsn\u0000KOldlKNiQAVIq9wC\u0000RI\u0000\u00005B\u0000tG7y\u0000wPmqsTJPWnID0G\u0000F7k\u0000WB4M0TGGjqpS\u000039\u0000o7kRVTJP\u0000NjDG0ZHMk0YP0H\u000012XDoT0e\u0000ldMgY/\u0000\u0000N0Tsuayv4R\u0000Sr+dVZf\u0000uGd\u0000\u0000BifKWuiN25FJS4Ua7p\u0000LkxTfTaswqOe1j3LrS4\u0000RrAQ1ZN\u0000PizTAak\u0000wAh\u0000MCufil2\u0000nMPUmLU\u0000ZFt\u0000KwrijDrMTf7\u0000JBpMJYvNM7sXwtrDw5+\u00003EgdgynT\u00004J\u0000w\u00001VI8L\u0000X9maDXxNjaqpMbU\u0000dZE\u0000m1/\u0000dlal\u00000aZncN\u0000oI7edddcxhYaRcAdDehAVJpDUc9eicj\u0000iLWTyHsG\u0000gz\u0000PFTJK\u0000R\u00003xE\u0000\u0000SaeHz1KCAC\u0000WRXlPmX\u0000Oc1\u0000\u0000unJb2H\u0000USw\u0000\u0000\u00009\u0000CzRlbxmTRJT\u0000JUOO1cc\u0000UPTZzaDSECtVbFwcF\u0000+VQu2\u0000\u0000KlTzIjlKGAWbynQOY+T0pIL\u0000pGUHFdTYqj\u0000\u0000NFbRRkaz8xApA6\u0000\u0000j0RUY2\u0000\u0000VfiB8LN\u00001jRbbW\u0000EMr\u0000W23GtHMYAkUZocHTBn3\u0000rq2\u00001ON\u0000iyiVFyq\u0000SogArAZNOJ6fEttYwS6fqqJQF\u0000deOYo\u0000j92iHpi\u0000UQbPXpfEWkxZD2nYrh1VJgx\u0000\u0000c1SPxniSGSdRHAdY4JG\u00008A\u0000DTl\u0000FDCKgx1OMAU\u0000rgMDKLcHk0JEc9Efx7o\u0000g3F\u0000Fv2K24A\u0000VhUfv\u0000w\u0000\u000075Uql/\u0000qP/A\u0000Hr\u0000Z5EBCsmctOTSJg/\u0000\u0000PsIeZ+WkhuTgYlAZv6\u0000GvDBwRURUJ4\u0000eHN\u0000zpc\u0000xbo\u0000jiserdFQe7CsYuWUvGxCtxS\u0000aJIGB5BFA3FKqw8WUKa\u0000NRy\u0000HB5BGGvlcnEZ\u0000B2ebbANEOaLXA3PCkC\u0000\u0000q8dASL\u0000FcjlDA4HdSjKCPxUOgwGx8O\u0000\u0000cuebN+\u0000ov3\u0000w\u00001Uem3cVnZeIoO\u0000fqg\u0000qpaAUZiWkG1HLx5\u0000RUcL3McSyTLRvrB\u0000VQOQ\u0000ap\u0000\u0000K+UkdRUyyGiuqAf2cyHY7y\u0000x0teEB4G\u00002DXLfU\u0000aT/AUl9skNsmUEl\u0000\u0000ux\u0000Qo6VgO2Wd5O\u0000osmHImh\u0000ycROr0Oel\u0000S\u0000lP2lLEnY\u00001l\u0000depUoVa\u0000potWiTMadBJ\u0000YcVlyzmJNlxCsHe\u0000SqdSJcoJlKC\u0000WJOaOkeBLG3\u0000tMk\u0000mfY\u0000TD5Wzx9Rrc1\u0000RQSWzCM\u0000ovm\u0000YPw\u0000sNtOXw9mwr7\u0000uaVUlidI3\u0000rah3gyeenerjLU0KPbMwy\u0000AqepHin\u0000QQuUHLuatMt\u0000ASgRg6Y\u0000vcN\u0000yTRG\u00008A\u0000nFXUsD+HEYN\u0000JUTEDCXakb8\u0000dvXQmYHps8ieNsj\u0000kMeptrxmgqbUS6ULmFWAzgHO\u00009ti0PRYC\u0000Dm\u0000jIR0Itlz6eK1Ii\u0000QDkeiAdNagUXBjhFdW3F2L9Hdn2UjLI\u0000e1cptBU\u0000w\u0000Y\u0000t70CdP/A\u0000ASTv\u0000vcWqHPBckemWT\u0000j20\u0000IR8pqZ4\u0000OErHMH5stMg\u00001yVaMRXNck0BzC3T2nxCGYqU\u0000XpXN6A\u0000TJuXdZG\u0000RgN\u0000Tzr\u0000TqKMbje\u0000ooSQDGscA0uKhiTAzembGXcpEv4PGaKe3A3REVbTxvj\u0000VCRTORYiYpJmWIC\u0000xfLGnFiOl0lHfIbbrdK\u0000wBn\u00001AAJuUD\u0000HOm\u0000\u0000pamtoaEyQRlZXwdNR6UqV2CODTe2NvHMZtbMIN\u0000KKA\u0000nz9K03e\u0000ctLdCSkSUu/\u0000vxUOQnpHHQ+Frm7lkj1Bvs8TIyqDlh7e1Ow\u0000RDp\u0000WyEN\u00007eRur4VfzlUC\u0000DpBnOarVsd1hU\u0000\u0000AqsTKd\u0000osN\u0000y4NZkkfNNe4dl68F\u0000Rm\u0000deQda1wTw8neNMcTFGx\u0000hgye1VbexOZcSIrD3nupZ9oeamKpktbDGaOKjyDHtYR\u0000iNHNfch\u0000JftLANG\u0000uUj\u0000X1FUJqYNQ0G\u0000K0beUYVpNQP\u0000IvgGfJ9agrIRR6FMO\u00001ldut\u0000GQx\u0000\u0000APJtvW\u0000\u0000XipnmS\u0000ma1TlIFJndIQ\u00008ji\u00005m\u0000aTX\u0000\u0000fbEen6an1ul\u00008AImrHfrKeUeYoVSESOMH5iCg/VjwK\u0000o7Bea5CF\u0000\u00003YvwS\u0000G\u0000/A\u0000Kgd0y1HMiKPQpfFugoMjU4m\u00008A\u0000kkjfySqlffzSFYJAtzO\u0000qHHbkD/A\u0000axX\u0000p4A1AyE\u0000mNiCR0KY8n\u0000FWD\u0000ApRbH7icxuzYu59a\u0000m3\u0000\u00004mmNSC\u0000I6RylN8QrCF\u0000GwvW\u0000pI\u0000UL0JaL/AUSVYP8AQ\u0000i/\u0000CB/iXjeiWV3mt1t\u0000CyMano7\u0000sh/UF0qDzIPW27Na1rH\u0000Hs2eEh8\u0000Wfp\u0000s9rcRuo\u00003WwJt2yF\u0000ObijyreTsc\u00000Lf\u0000\u00003S\u0000c4rs\u00003j\u0000n2UP\u0000Ofy\u0000FcdsMdRFzb\u0000qbLIS4+Z\u00009BXM2ZmbWhe\u0000XFyjUA\u0000zgdA\u0000o1TUnPSLrVbjurNDxy\u0000hDyi\u0000T/A\u0000tXiOg6VIWBa\u00009npQzWBeqG\u0000M7j\u0000aAG\u0000dIhDKRLEijH\u0000jC7\u0000\u0000maieHps\u0000aaLkOmaFzfcdg8Tn21aXV5T\u0000NV\u0000Jdw\u00001Qmck1DZ\u0000x0\u0000pXOaaMzEsCnZyWARqUg\u0000QOPOgvH\u0000x9DS\u0000Le\u0000gaQdtPm\u0000KLteQOMT1oJIlOQ\u0000PNP\u0000lQOa\u0000JpNvFK\u0000rtDSi46ChQUI\u0000jFDSAVHpo9RRZFmk3x\u00003OiKpfVa\u0000cjmVy1\u0000J9NpKPSPEMRsvftbuElGuiAazBKCOtS\u0000eFAUPdHQDpWMqTN\u0000WmlpW0P\u0000RWlyi1GFdMnJAEkQ3RN\u0000lS6fhTXJtqMAlhj\u0000Lu3PSS3yzj8Dx6tcR9n\u0000e3dTado\u0000qEc\u0000HN5ZtqR\u0000XV+HtK8Gqa3\u0000EthaGc/\u0000\u0000bSln25fn8RXDUo\u00002KmFS5aSNSBEofhYNpl\u0000aaP\u0000ZbMdv57\u0000\u00005J\u0000jVm\u0000O5R\u0000tEf\u0000Uuf\u0000WeZAuiP\u0000Ke8\u0000Ub7\u0000H7f\u00001vvyWhr\u0000U6Fa\u0000OBehDSTJn3EzvTesJal2la\u0000LP8\u0000CwB\u0000\u0000xr\u0000\u00008OeQkl\u0000nInULPnpirl\u00001OSUeIoYeZHc\u0000r1Jb2m\u00001Nlm1tA\u0000LyhsCFv\u0000xA6\u00000wvi\u0000r7\u0000xvEdg4AUD1NJLus\u0000QWTim5I\u0000\u000056\u0000nMm\u000029uDjW2\u0000cVt\u0000dhAPKjcdmdxsakrZ\u0000OSPhWpSSc0d\u0000c0\u0000\u0000QiT\u0000KVeAJVOKjjHOmyT\u0000xU\u0000dhaBj7XNRKwA\u0000GGea8rcHFAFW5mYE4NV1qGLM06cM81XLI5FAu8JDfrUkU7Zq1nL\u0000kVPLtlpqUgN\u0000C9KeMHydFLeCQf\u0000QEkBvhkGrL5\u0000gIrFmYYCYMs\u0000qAVSW8a\u0000\u00008pV2GcBjz+aTGKa\u0000fK\u0000qE+TuD5IPtP\u0000TO7eEjAaokiiz9F\u0000n9Ksux+Gf8ATZ4e\u0000w\u0000A\u0000\u0000qGpfVGY\u00009UMB5+YLeDUniaNvdT\u0000fyKU3QfcqFVRs3g\u0000\u0000kPSYhT\u00002c1\u0000HMdXsHtOGoeNLBWU\u0000DB\u0000nbPbK\u0000g\u0000w\u0000fW\u00009/TkCG\u0000xggVpf8DbEJmupaloIM\u0000CFOOyjJPp12ybPOseEYDjpVIlidZTJce\u0000Xt\u0000\u0000QoCiqgDoFcZZAa\u0000ffJI3HnJ\u0000dP\u0000oMW\u0000\u0000CM\u0000xE0\u0000mRgGaMsTzdaYc6/cR0qKR9xiAso\u0000SB+KbIfaZQ/\u0000QIu\u0000tWmZyF9ehgOFppZHYAR\u0000aFpaJJJ\u0000VdyMtWCdeZBVIuAePSl\u0000mxGDVUscMUgJA6DVy0OW\u0000ZQl\u0000WrZeltLSOZs\u0000gYAt2AItOv\u0000\u0000JLSFiVCPiIU3a3\u0000Ztu\u0000lRKstB0\u0000avImDI2\u0000tPzVqJqA\u0000VwT2iLJqeqT2P2NW4XCpv0NSaa\u0000ZOsMs\u0000ImjthDTs1a0axfVtX\u0000r\u0000MZ\u00008yiPoT\u0000ulSinr/A\u0000KtNLPfB\u0000ipLguy\u0000mYgYq9v\u0000U7W\u0000l8DmnNdE2I1shUDZCgQYGKg\u0000nNWOXKa\u0000kxCf3x9BV55\u0000ljgGaD/AC1OKkkbKLWA\u0000WHd\u0000dFSFfiAFVnb\u0000g1Z\u0000swplk4bCCiF\u0000JMcK\u0000VEX\u0000AG\u0000E6Y\u0000R2VAsyWIZlq\u0000sqoit5yaBoJH\u00003k\u0000E0gBa\u0000R\u0000nLNMDZNTMY+\u0000kwiHcPVVZQaXVT/AHUePWs7\u0000\u0000KtMC00\u0000Hmhel8k\u00002tmMaIyCxLQyl8z\u0000aubUrNX\u0000PzgKAN2LAxg\u0000a5F\u0000\u0000vLZeB0\u0000RQ4Wg\u00002mopc\u0000CfZF\u0000zCaM\u0000kd\u00006HsZCs\u0000ZTWWxkx\u0000g4/Oeu8FuD7G21j\u0000RWWcKiAZDlQWvKrbeQF\u0000AMV\u0000uF4BLyk\u0000eOPNwArH\u0000CK\u0000oPbN3CxflYHcRwa\u0000rVB\u0000Kz7\u0000ABIUbi9U\u00005rm\u0000PILIkImzDpsY\u0000f\u0000wv3NSuZG\u0000UCJYfy\u0000bV7\u0000VG2\u0000UvV\u0000TvQBBcMQuGYD0pbdpWo\u0000qegRYy2f\u0000Y1CXCG\u0000UkB\u0000CWq\u0000MGaYUnycdimKxvSMOPTQ3OpG\u0000mR\u0000Lg+ibJ3\u0000\u0000G1LoZt\u0000rVjK2aKA\u0000E5ac3We\u0000u2beW0VonJ\u0000p9rWrdw\u0000\u0000ANezU/KKrnpZVPTuYkJtG0CYoAlgCaa20yDgc1LkUAW3I2\u0000\u0000W6Tp\u0000K\u0000dhBV\u0000SQBOtZNzN8\u0000bgpTc9T\u0000KlNO\u0000h3cc66MHsa\u0000\u00007BFJak\u00000vRE\u0000xIBovVsqj3Jyaa\u0000FUTO\u000002p\u0000jZEeBz\u0000FU8\u0000EqD\u0000bJvW3TSBOpYCdeRdzVaMivaKCcm\u0000T\u0000FQWmnFWiXEJJpp\u00002f\u0000xpsQpFE\u0000uY0RA5FIRcT\u0000UtVaL3pe0o/cGmk\u00003PTFImNSAciaKkHUUiMd\u0000MwNWB/HXQSpN\u0000wHWqdl\u0000SZiQBbS\u0000svFIziS\u0000ltU2LZdK1UT\u0000fA\u0000H19\u0000\u0000CqAnKc\u0000AdBmRzW\u0000JLU\u0000ZDpWBos\u0000qFVBqVsiWLAGO5PmQBbsp6lSIFJao\u0000ETk1LaPOgDmXbU3kGHp96bMTGaz3P\u0000VebmXlS\u0000J2i\u0000\u0000k0\u0000P2KitWW\u0000HuGl0n/AU9I\u0000Naf\u0000c04\u00003DZW\u0000NOdKtVPUHjsefA\u0000\u0000c4TvIc\u0000\u00008AfFdIOZn0aOxwVlZl\u00002DFSzcQyYnbmUs/\u0000ZL1ezEyJPr1LH1FRS7feKLqKAHafqmqUtTU\u0000wBXV\u0000brTAmP\u0000YTrQvShedJgPrVg\u0000y3Z\u0000bS8elYWiv28fSgCEVlapUL3yOum\u0000XtWLaT/ACy/\u0000TU9Q\u00007C\u0000pZSTqV1lSK0evDypkjNcJ4U\u0000obpXNS/\u0000Hg3\u0000qWoDUq/EtlaI0cUUlxMDq3FHo1T\u0000w\u0000E\u0000H7QOv8AI371epe9\u0000w\u0000P\u0000T21DQXH\u0000tk="
# 解码为二进制数据
img_data = base64.b64decode(b64_str)
# 将二进制数据写入文件
with open("image.png", "wb") as f:
f.write(img_data)
python base64Test.py
报错:
E:\20230220_otherPrj\20230220_base64Test>python base64Test.py
Traceback (most recent call last):
File "base64Test.py", line 7, in <module>
img_data = base64.b64decode(b64_str)
File "C:\Users\Arnold\AppData\Local\Programs\Python\Python38\lib\base64.py", line 87, in b64decode
return binascii.a2b_base64(s)
binascii.Error: Invalid base64-encoded string: number of data characters (7121) cannot be 1 more than a multiple of 4
E:\20230220_otherPrj\20230220_base64Test>
问题产生原因(失败,报错不是这个问题)
这个错误提示说明你的Base64字符串长度不是4的倍数,因此无法正确解码。这是因为Base64编码是将3个字节的二进制数据转换为4个字符,如果原始数据长度不是3的倍数,编码器会进行一些填充操作,以便使编码后的字符串长度是4的倍数。
在Python中,使用标准库中的base64模块进行解码时,如果遇到这种情况,会自动将字符串末尾的填充字符去除。但如果去除填充字符后字符串长度仍不是4的倍数,就会出现类似的错误提示。
为了解决这个问题,可以在解码之前手动将Base64字符串的末尾补上适当的填充字符,使字符串长度是4的倍数。填充字符通常为等号=,用于表示数据的结尾。例如,如果字符串长度除以4余1,就需要在末尾添加3个等号;如果余2,就需要添加2个等号;如果余3,就不需要添加任何等号。
修改后代码(增加填充=
功能):
base64Test.py
import base64
# 带有不足4个字符的Base64编码字符串
b64_str = "把上面代码的Base64编码字符串拷贝过来,太多了,博文放不下!"
# 计算需要添加的等号数
num_padding = 4 - (len(b64_str) % 4)
if num_padding < 4:
b64_str += "=" * num_padding
# 解码为二进制数据
img_data = base64.b64decode(b64_str)
# 将二进制数据写入文件
with open("image.png", "wb") as f:
f.write(img_data)
还是不行啊,失败了,之后咨询cw怎么解决吧
可能是序列化的原因
20230223 问题产生原因2:base64编码数据是错误的
E:\20230220_otherPrj\20230220_base64Test\base64Test.py文章来源:https://www.toymoban.com/news/detail-432914.html
import base64
# Base64编码的字符串
b64_str = "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"
# 解码为二进制数据
img_data = base64.b64decode(b64_str)
# 将二进制数据写入文件
with open("image.png", "wb") as f:
f.write(img_data)
结果:生成了一张图片文章来源地址https://www.toymoban.com/news/detail-432914.html
到了这里,关于python解码bash64报错:binascii.Error: Invalid base64-encoded string: number of data characters (7121) can的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!