小编cmp*_*ezg的帖子

将 Base 64 字符串解码为文件

我正在编写一个从设备接收 Base 64 字符串的程序。该字符串是一个编码的 json 文件,我想这样解释它。

\n\n

如果我这样做(使用 python base64 库):

\n\n
decoded = base64.decodestring(base64str) \nprint(decoded) \n
Run Code Online (Sandbox Code Playgroud)\n\n

然后它打印出一堆乱码,因为原始数据不是字符串,而是文件。

\n\n

我可以看到乱码之间的文件名,所以我想我正确接收了数据,但需要将其直接解释为文件而不是字符串。

\n\n

我环顾四周并没有成功。尝试将字符串保存到文件中显然只会将所有乱码保存到文件中

\n\n

我将非常感谢您帮助如何做到这一点!

\n\n

64 进制字符串:

\n\n
UEsDBBQACAAIAAAAIQAAAAAAAAAAAEEfAAALACAAbzNkM3h4Lmpzb25VVA0ABwAAAAAAAAAAAAAAAHV4CwABBAAAAAAEAAAAAO1ZbW/iOBD+vr8C5ev1UBIKtNwnlpc2UnlZoHvb3a6QSQxYm8RZxymwK/77zTiBJkB4OfWk+1CkqrbzPDOT8Xg8dn5/KMBPqweBy2wiGfdDrVb4pkbx93vbUrgmDW3BAsQBTNOuso8tj8yoaHB/ymaRIAnsWwa0L3VLr0eSt5YBDyNBO2T5wP3ZcM6FbBNbcgGSyvrVGUzm7zPNM4gDOqWC+jbtc+bLL8C6ubmY9gS0SuUS2qBnoS9/P2vQCp+12jdoMgca+tWzNhM8CpK2XAUUmgCktnzWYGTBHDmHIaOEz+eUzeYSuzp2iT9zaUK1qS+pGC+hCy+17a+gX6msv6+1SywegR1gct5kNObE96l7DOGyIGD+7COXknsANErGCWgjmnDmJI76AnMMlhf+LBWvdfPGLNE/SjdXBXxA8BULu+NPeYSnHMLXPMLXA4Rc722Mf6BTeYY7Bjh96I1q+QRyxINj8rgvmR/xKExPHxCmxA1pDqnlk4lL6x4kAhk5tMGFgCiLV7AU0XFam4SyLejPCMJjdZaiNnMhALfqVOY4S5PiNVkoCUTi2TRcMWyapLg9rafNzfB3tR+lJ94fMY+qDKbnzVoa+QAaMNYNs/wX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qWwI9c9733/++pTnKo0upw6LRd2o28iboL0nqlZkkvJcGhNekLs3HiX++ItLot2QtNH7sy4XJCZBoylERGeODT6s304/zvM4lBm2g0amb6YUvOqfCpbDPqOh+VZOPI45YPKxCOzCEC9TQQl5p6tTbzWTinTof599x1kpskIwNe4rILmd2A5DcZcPXJ5Sjg6RTg61HASBA/PK5EQY6rUZBdRVavSSdQqdnx1VT2PhqeggjwYGrqhwsm7fmeFHU/lUxSegasft1xBDg8/ri2y8PUiS6GfcALtt9pdlCb43+XLgoh9UMu0iHQC/D+DcxP8lia2e/i+2H8bGSkmX0Shgsoe1V4Q57EK4OdK/Et5p6E8z0+HgoEl9zm7mcqwjh4SzsI2Pv7XOCteFnXM3E0JC8UygLJhVoXYU/5eevgnbkYUoEvMqCB+j7IXAoRPZ2qBWeU84Bofz4wRJvR/1CGoOlp63D3QM9GgrYFhzoKAWa1UqweAZknQFbnSwU9YRbL5u3t7U21elvKQbpuhMjrYvUWf2apqqc+T2qPQbI09aJplPRy8qsoRLJHaW0mvAURceYoVgBpXG8SXZdKmNgf2UzXqTeSeEWKrtd0s6YbtWu9Vq7WStfp2U/4w4CqwMlMLMwms63+y3VKmHFrFo3KTVEvVm61g+A7iMEFWWXBpm4cRg+jCZjQISG+gmaWy8XNX/qrC94/N+8bfS197bz+sP7wD1BLBwiTXw4cIAcAAEEfAABQSwECFAMUAAgACAAAACEAk18OHCAHAABBHwAACwANAAAAAAAAAAAApIEAAAAAbzNkM3h4Lmpzb25VVAUABwAAAAB1eAAAUEsFBgAAAAABAAEARgAAAHkHAAAAAA==\n
Run Code Online (Sandbox Code Playgroud)\n\n

“解码”的字符串:

\n\n
!A ux o3d3xx.jsonUT   \xef\xbf\xbdYmo\xef\xbf\xbd8\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbdP \xef\xbf\xbd\xef\xbf\xbd\'\xef\xbf\xbd\xef\xbf\xbd6RyY\xef\xbf\xbd{\xef\xbf\xbd\xdd\xae\xef\xbf\xbdI m\xef\xbf\xbd\xef\xbf\xbdL\xd3\xae\xef\xbf\xbd\xef\xbf\xbd-\xef\xbf\xbd\xcc\xa8hp\xef\xbf\xbdf\xef\xbf\xbd X\xef\xbf\xbd[\xef\xbf\xbd/uK\xef\xbf\xbdG\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd#A;d\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbdp\xce\x85l[r\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbdL\xef\xbf\xbd\xef\xbf\xbd3\xef\xbf\xbd3\xef\xbf\xbd:\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd6\xef\xbf\xbds\xef\xbf\xbd\xef\xbf\xbd/\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbdJ\xef\xbf\xbd\xda\xa0g\xef\xbf\xbd/?k\xef\xbf\xbd \xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd7h2\xef\xbf\xbd\xd5\xb36< \xef\xbf\xbd\xef\xbf\xbd\\\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd|\xef\xbf\xbd`d\xef\xbf\xbd9\xef\xbf\xbd!\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd:v\xef\xbf\xbd?siB\xef\xbf\xbd\xef\xbf\xbd/\xef\xbf\xbd/\xef\xbf\xbd\n                                  /\xef\xbf\xbd\xef\xbf\xbd_\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbdK,\xef\xbf\xbd`r\xef\xbf\xbdd4\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd{ J\xef\xbf\xbd                                                      \xef\xbf\xbd `\xef\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ef\xbf\xbd\xef\xbf\xbd6\xef\xbf\xbd\xef\xbf\xbdH\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbdZV(j7\xef\xbf\xbd`\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xa5\x8et\xef\xbf\xbd(\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd:\xef\xbf\xbdS\xef\xbf\xbd^\xef\xbf\xbd\xef\xbf\xbdo^t\xef\xbf\xbd\xef\xbf\xbdfl?I\xef\xbf\xbd\xef\xbf\xbd9N\xef\xbf\xbd,\xef\xbf\xbdG\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbdA\xef\xbf\xbd\xc5\xb7 \xef\xbf\xbd\xef\xbf\xbda\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\\\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbdNr\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbdp\xef\xbf\xbd]\xda\x8d\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd \xef\xbf\xbd\xef\xbf\xbdR\xef\xbf\xbd,\xef\xbf\xbd\xef\xbf\xbdm@\xef\xbf\xbd\xef\xbf\xbdS\xef\xbf\xbdD\xef\xbf\xbd\xef\xbf\xbd9\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbduZ\xef\xbf\xbd4\xef\xbf\xbd,\xef\xbf\xbdr(,\xef\xbf\xbdE\xef\xbf\xbd\xd6\xabhCv@C\xef\xbf\xbdFIX\xef\xbf\xbd:                         \xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbdZ\xef\xbf\xbd0\xef\xbf\xbd                                                                \xef\xbf\xbdz\xef\xbf\xbdfI /%\xef\xbf\xbd\xef\xbf\xbd5\xef\xbf\xbd                                       \xef\xbf\xbdU\xef\xbf\xbd\xef\xbf\xbdo\xef\xbf\xbds\xef\xbf\xbd\'R\xef\xbf\xbdp\xef\xbf\xbdyT\xef\xbf\xbd\xef\xbf\xbdh.h8\xef\xbf\xbd.&\xef\xbf\xbdx\xef\xbf\xbd\xef\xbf\xbdQ/\xef\xbf\xbd\xef\xbf\xbd_\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\n      \xef\xbf\xbdq\xef\xbf\xbd_\xef\x88\xb4\xef\xbf\xbd-\xef\xbf\xbd                                                                   -\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd`F\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd)F]\xef\xbf\xbd \xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd \xef\xbf\xbd\xef\xbf\xbdtXU\xef\xbf\xbd*\xef\xbf\xbd`M\xef\xbf\xbd2\xef\xbf\xbdrBd2\xef\xbf\xbdDFx\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd3\xef\xbf\xbdA\xef\xbf\xbdh4jf\xef\xbf\xbdaK\xce\xa9\xef\xbf\xbdl3\xef\xbf\xbd:\xef\xbf\xbdd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd+\xef\xbf\xbd\xef\xbf\xbd!\xef\xbf\xbd4\xef\xbf\xbd\xef\xbf\xbdz\xef\xbf\xbd6\xef\xbf\xbdY8\xef\xbf\xbdN\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbdu\xef\xbf\xbd\xef\xbf\xbd$#^\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd0:q\xef\xbf\xbd\xef\xbf\xbd#LHay\xef\xbf\xbdF\xef\xbf\xbd\xef\xbf\xbd%-\xef\xbf\xbdI\xef\xbf\xbdj^%M\xef\xbf\xbd\xef\xbf\xbdTHFc\xef\xbf\xbd\xef\xbf\xbduW}\xef\xbf\xbd;n}nuGc\xef\xbf\xbdS\xef\xbf\xbdk\xef\xbf\xbd\xef\xbf\xbdO\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbdY\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd[\xef\xbf\xbd\xef\xbf\xbdV3\xef\xbf\xbd@)5O*\xef\xbf\xbd\xef\xbf\xbd/\xef\xbf\xbd9h\xd5\x9bO\xef\xbf\xbdvo0\n                  \xe2\xa0\x9e\xef\xbf\xbd\xdf\xb4\xef\xbf\xbdQ\xef\xbf\xbda\xef\xbf\xbd~\xef\xbf\xbd\xef\xbf\xbd|R\xef\xbf\xbda\xef\xbf\xbd^\xef\xbf\xbd<\xef\xbf\xbd\xc6\x876\xef\xbf\xbd\xef\xbf\xbd+\xc5\x8d\xef\xbf\xbd\xda\xa0\'\'\xef\xbf\xbd1s\xef\xbf\xbd+5\xef\xbf\xbd\xef\xbf\xbd+\xef\xbf\xbd\xef\xbf\xbd     \xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd                \xef\xbf\xbd\xdd\x80\xef\xbf\xbd7p\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd(\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbdQ\xef\xbf\xbdH?<\xef\xbf\xbdDA\xef\xbf\xbd\xef\xbf\xbdQ\xef\xbf\xbd]EV\xef\xbf\xbdI\'P\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbdT\xef\xbf\xbd>\xef\xbf\xbd\xef\xbf\xbd`j\xef\xbf\xbd c       4\xef\xbf\xbdA\xef\xbf\xbd\xef\xbf\xbdW>%\xef\xbf\xbd\xd8\x95\xef\xbf\xbd\xde\xad7\xef\xbf\xbd,7[\xef\xbf\xbd                                                     &\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbdu?\xef\xbf\xbdLRz\xef\xbf\xbd~\xef\xbf\xbdq8<\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xd4\x89.\xef\xbf\xbd}\xef\xbf\xbd \xef\xbf\xbd.Q\xef\xbf\xbdY\\H\xef\xbf\xbdT\xd1\xbf+\xef\xbf\xbdK\xef\xbf\xbdR \xef\xbf\xbd0#\xef\xbf\xbd\xef\xbf\xbdfZ\xef\xbf\xbdfv\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd#W\xef\xbf\xbd9\xef\xbf\xbd\xef\xbf\xbdZM`\xef\xbf\xbdKV<\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd?u\xef\xbf\xbdM\xef\xbf\xbd\xef\xbf\xbdi\xca\x85G\xd4\xab#\xef\xbf\xbd!\xef\xbf\xbd@\xef\xbf\xbd\xef\xbf\xbdX\xef\xbf\xbd1z\xef\xbf\xbd|"V1\xef\xbf\xbd               \xef\xbf\xbd\xef\xbf\xbdivP\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd. !\xef\xbf\xbdC.\xef\xbf\xbd!\xef\xbf\xbd                                                     g#d\xef\xbf\xbd\xef\xbf\xbd9$UhR\xef\xbf\xbdz\xef\xbf\xbdZ`\xef\xbf\xbd \xef\xbf\xbdO\xef\xbf\xbdX\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbda\xef\xbf\xbdld\xef\xbf\xbd\xef\xbf\xbd}\xef\xbf\xbd"\xef\xbf\xbd\n                 ({UxC\xef\xbf\xbd\xef\xbf\xbd+\xef\xbf\xbd\xef\xbf\xbd+\xef\xbf\xbd-\xe6\x9e\x84\xef\xbf\xbd=> \xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbdg*\xef\xbf\xbd8xK\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\\\xef\xbf\xbdxY\xef\xbf\xbd3q4$/\xef\xbf\xbd\xc9\x85ZaO\xef\xbf\xbdy\xef\xbf\xbd\xef\xbf\xbdR\xef\xbf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\xbdnF\xef\xbf\xbd \xef\xbf\xbd\xef\xbf\xbd!!\xef\xbf\xbd\xef\xbf\xbdf\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd_\xef\xbf\xbd\xef\xbf\xbd\n                                                                                                                                                      \xef\xbf\xbd?7\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbdP\xef\xbf\xbd_ A!\xef\xbf\xbd_ A …
Run Code Online (Sandbox Code Playgroud)

python file decoding

2
推荐指数
1
解决办法
2476
查看次数

使用async.js的嵌套循环

我想做一个非常简单的代码,我在javascript中有两个嵌套循环,打印出它们当前所在的索引.(它是我想做的其他事情的基础).内循环有一个计时器,因此在打印每个数字之前应等待1秒钟.

我希望这个输出:

outer count: 0
inner count: 0
inner count: 1
inner count: 2
inner count: 3
inner count: 4
in out 
outer count: 1
inner count: 0
inner count: 1
inner count: 2
inner count: 3
inner count: 4
in out
Run Code Online (Sandbox Code Playgroud)

等,但这不会发生.我的代码中有一些明显的错误吗?函数甚至可以嵌套,可以异步吗?请帮忙!:(

到目前为止这是我的代码:

var count = 1;
        async.whilst(
        function() {return count < 5},
        function(callback){


            var icount = 0;

            console.log("outer count:" + count);

            async.whilst(
                function () { return icount < 5; },
                function (callback) {
                    console.log("inner count:" + icount);
                    icount++; …
Run Code Online (Sandbox Code Playgroud)

javascript loops asynchronous async.js

0
推荐指数
1
解决办法
703
查看次数

为什么我不能使用int的第一位?

我试图使用int的所有位生成一个随机数.当我使用rand()函数时,它似乎永远不会使用第一位,所以我试图把整个东西移到一个地方.但是,当我尝试打印新移位的数字时,它总是打印4294967295,所以我猜这是一个溢出.为什么我不能使用那个位呢?有办法吗?

如果没有使用第一位,它就可以正常工作(打印是在随机数移位之前和之后):

00000100001100111111001010010111
00001000011001111110010100101110
Run Code Online (Sandbox Code Playgroud)

但如果需要第一位,则会发生以下情况:

01010110100001110011110011011111
42949672950101101000011100111100110111110
Run Code Online (Sandbox Code Playgroud)

请帮忙!!它在技术上有效,它只是先输出数字......

 typedef struct{
    int blocks[NUM_BLOCKS];
} WWord;

void printbits(unsigned int n){
    int i;
    //printf("%u = ",n);
    for(i=SIZE_OF_INT*SIZE_OF_BYTE-1;i>=0;i--){
        int mask = 1<<i;
        int maskedn = n&mask;
        int thebit = maskedn >> i;
        printf("%u",thebit);
    }
    printf("\n");
}

void fillword(WWord *word){
    int i;
    for(i=0; i<NUM_BLOCKS;i++){
        unsigned int ran = rand();
        printbits(ran);
        ran = ran<<1;
        printbits(ran);
        word->blocks[i] = ran;
        //word->blocks[i]<<1;
        printf("\n");
    }
}
Run Code Online (Sandbox Code Playgroud)

c bit-manipulation shift

0
推荐指数
1
解决办法
166
查看次数