1. <small id='xGfgN'></small><noframes id='xGfgN'>

    2. <legend id='xGfgN'><style id='xGfgN'><dir id='xGfgN'><q id='xGfgN'></q></dir></style></legend>
        <tfoot id='xGfgN'></tfoot>
          <bdo id='xGfgN'></bdo><ul id='xGfgN'></ul>

        <i id='xGfgN'><tr id='xGfgN'><dt id='xGfgN'><q id='xGfgN'><span id='xGfgN'><b id='xGfgN'><form id='xGfgN'><ins id='xGfgN'></ins><ul id='xGfgN'></ul><sub id='xGfgN'></sub></form><legend id='xGfgN'></legend><bdo id='xGfgN'><pre id='xGfgN'><center id='xGfgN'></center></pre></bdo></b><th id='xGfgN'></th></span></q></dt></tr></i><div id='xGfgN'><tfoot id='xGfgN'></tfoot><dl id='xGfgN'><fieldset id='xGfgN'></fieldset></dl></div>
      1. 在 Python 3 中将整数的字符串表示形式编码为 base64

        Encode string representation of integer to base64 in Python 3(在 Python 3 中将整数的字符串表示形式编码为 base64)
          1. <tfoot id='AZCmu'></tfoot>

            <small id='AZCmu'></small><noframes id='AZCmu'>

              <tbody id='AZCmu'></tbody>
          2. <i id='AZCmu'><tr id='AZCmu'><dt id='AZCmu'><q id='AZCmu'><span id='AZCmu'><b id='AZCmu'><form id='AZCmu'><ins id='AZCmu'></ins><ul id='AZCmu'></ul><sub id='AZCmu'></sub></form><legend id='AZCmu'></legend><bdo id='AZCmu'><pre id='AZCmu'><center id='AZCmu'></center></pre></bdo></b><th id='AZCmu'></th></span></q></dt></tr></i><div id='AZCmu'><tfoot id='AZCmu'></tfoot><dl id='AZCmu'><fieldset id='AZCmu'></fieldset></dl></div>

              <legend id='AZCmu'><style id='AZCmu'><dir id='AZCmu'><q id='AZCmu'></q></dir></style></legend>

                <bdo id='AZCmu'></bdo><ul id='AZCmu'></ul>

                  本文介绍了在 Python 3 中将整数的字符串表示形式编码为 base64的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在尝试将 int 编码为 base64,我正在这样做:

                  I'm trying to encode an int in to base64, i'm doing that:

                  foo = 1
                  base64.b64encode(bytes(foo))
                  

                  预期输出: 'MQ=='

                  给定输出: b'AA=='

                  我做错了什么?

                  在 Python 2.7.2 中可以正常工作

                  in Python 2.7.2 works correctly

                  推荐答案

                  试试这个:

                  foo = 1
                  base64.b64encode(bytes([foo]))
                  

                  foo = 1
                  base64.b64encode(bytes(str(foo), 'ascii'))
                  # Or, roughly equivalently:
                  base64.b64encode(str(foo).encode('ascii'))
                  

                  第一个示例对 1 字节整数 1 进行编码.第二个示例编码 1 字节字符串 '1'.

                  The first example encodes the 1-byte integer 1. The 2nd example encodes the 1-byte character string '1'.

                  这篇关于在 Python 3 中将整数的字符串表示形式编码为 base64的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  groupby multiple coords along a single dimension in xarray(在xarray中按单个维度的多个坐标分组)
                  Group by and Sum in Pandas without losing columns(Pandas中的GROUP BY AND SUM不丢失列)
                  Group by + New Column + Grab value former row based on conditionals(GROUP BY+新列+基于条件的前一行抓取值)
                  Groupby and interpolate in Pandas(PANDA中的Groupby算法和插值算法)
                  Pandas - Group Rows based on a column and replace NaN with non-null values(PANAS-基于列对行进行分组,并将NaN替换为非空值)
                  Grouping pandas DataFrame by 10 minute intervals(按10分钟间隔对 pandas 数据帧进行分组)
                        <legend id='ZFnO8'><style id='ZFnO8'><dir id='ZFnO8'><q id='ZFnO8'></q></dir></style></legend>
                        <i id='ZFnO8'><tr id='ZFnO8'><dt id='ZFnO8'><q id='ZFnO8'><span id='ZFnO8'><b id='ZFnO8'><form id='ZFnO8'><ins id='ZFnO8'></ins><ul id='ZFnO8'></ul><sub id='ZFnO8'></sub></form><legend id='ZFnO8'></legend><bdo id='ZFnO8'><pre id='ZFnO8'><center id='ZFnO8'></center></pre></bdo></b><th id='ZFnO8'></th></span></q></dt></tr></i><div id='ZFnO8'><tfoot id='ZFnO8'></tfoot><dl id='ZFnO8'><fieldset id='ZFnO8'></fieldset></dl></div>
                          <tbody id='ZFnO8'></tbody>
                        • <bdo id='ZFnO8'></bdo><ul id='ZFnO8'></ul>
                          <tfoot id='ZFnO8'></tfoot>
                        • <small id='ZFnO8'></small><noframes id='ZFnO8'>