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

  • <legend id='gjR80'><style id='gjR80'><dir id='gjR80'><q id='gjR80'></q></dir></style></legend>
    <tfoot id='gjR80'></tfoot>

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

        TypeError:没有编码的字符串参数

        TypeError: string argument without an encoding(TypeError:没有编码的字符串参数)
        • <legend id='Zi6bc'><style id='Zi6bc'><dir id='Zi6bc'><q id='Zi6bc'></q></dir></style></legend>

              <tbody id='Zi6bc'></tbody>

          1. <tfoot id='Zi6bc'></tfoot>

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

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

                  本文介绍了TypeError:没有编码的字符串参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我想将 Json 的压缩 gzip 上传到 Google 存储中.

                  I want to upload compressed gzip of Json into Google Storage.

                  我有这个代码:

                  import datalab.storage as storage
                  import gzip
                  path = prefix + '/orders_newline.json.gz'
                  storage.Bucket('orders').item(path).write_to(gzip.compress(bytes(create_jsonlines(source)),encoding='utf8'), 'application/json')
                  

                  create_jsonlines(source) 是一个返回 Json Newline Delimited 的函数.

                  The create_jsonlines(source) is a function that returns Json Newline Delimited.

                  运行此代码给出:

                  TypeError: string argument without an encoding
                  

                  Python docs 表示格式为:bytes([source[, encoding[, errors]]]) 我不确定我是否理解它,因为没有如何使用它的示例.

                  The Python docs says the format is: bytes([source[, encoding[, errors]]]) I'm not sure I understand it as there is no example of how to use it.

                  我也试过了

                  bytes([(create_jsonlines(source))[,encoding='utf8']])
                  

                  这给出了:

                  SyntaxError: invalid syntax
                  

                  我正在运行 Python 3.5

                  I'm running Python 3.5

                  推荐答案

                  您没有正确使用 bytes 函数.检查这个:

                  You are not using the bytes function correctly. Check this:

                  >>> a = "hi"
                  >>> bytes(a, encoding='utf8')
                  b'hi'
                  

                  你可以试试:

                  bytes((create_jsonlines(source)), encoding='utf8')
                  

                  encodingbytes 函数的参数,您在该函数之外使用它.

                  encoding is the argument of the bytes function, and you are using it outside of that function.

                  这篇关于TypeError:没有编码的字符串参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  What happens when you compare 2 pandas Series(当你比较 2 个 pandas 系列时会发生什么)
                  Quickly find differences between two large text files(快速查找两个大文本文件之间的差异)
                  Python - Compare 2 files and output differences(Python - 比较 2 个文件和输出差异)
                  Why do comparisions between very large float values fail in python?(为什么在 python 中非常大的浮点值之间的比较会失败?)
                  Dictionary merge by updating but not overwriting if value exists(字典通过更新合并,但如果值存在则不覆盖)
                  Find entries of one text file in another file in python(在python中的另一个文件中查找一个文本文件的条目)

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

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

                              <tbody id='kBdJM'></tbody>
                          1. <small id='kBdJM'></small><noframes id='kBdJM'>