Encoding/Decoding B64 zip file into a text and vice versa Python 3Best way to convert text files between character sets?How can I detect the encoding/codepage of a text fileSetting the correct encoding when piping stdout in PythonPython base64.decode does not seem to work on windowsPython Print String To Text FileWorking with utf-8 encoding in Python sourceHow do I decode a base64 encoded string?How do I see the current encoding of a file in Sublime Text?How do I find all files containing specific text on Linux?ascii decoding error in an ascii file (Python 3.5)

How effective would a full set of plate armor be against wild animals found in temperate regions (bears, snakes, wolves)?

Is it possible to have battery technology that can't be duplicated?

Must a CPU have a GPU if the motherboard provides a display port (when there isn't any separate video card)?

Am I being demoted?

Why is it bad to use your whole foot in rock climbing

Was the Lonely Mountain, where Smaug lived, a volcano?

Jam with honey & without pectin has a saucy consistency always

Boss making me feel guilty for leaving the company at the end of my internship

The best in flight meal option for those suffering from reflux

What publication claimed that Michael Jackson died in a nuclear holocaust?

What is the color associated with lukewarm?

Why can't we feel the Earth's revolution?

Optimising matrix generation time

Writing mathematical symbol with bold

Do Veracrypt encrypted volumes have any kind of brute force protection?

Why are backslashes included in this shell script?

How to turn a table by 90° and split variables in two or more lines

Why is C++ template use not recommended in space/radiated environment?

Opposite of "Concerto Grosso"?

Why did the Death Eaters wait to reopen the Chamber of Secrets?

Does WiFi affect the quality of images downloaded from the internet?

Are large format prints more brittle?

ISP is not hashing the password I log in with online. Should I take any action?

What happens when one target of Paradoxical Outcome becomes illegal?



Encoding/Decoding B64 zip file into a text and vice versa Python 3


Best way to convert text files between character sets?How can I detect the encoding/codepage of a text fileSetting the correct encoding when piping stdout in PythonPython base64.decode does not seem to work on windowsPython Print String To Text FileWorking with utf-8 encoding in Python sourceHow do I decode a base64 encoded string?How do I see the current encoding of a file in Sublime Text?How do I find all files containing specific text on Linux?ascii decoding error in an ascii file (Python 3.5)






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















I have a zip file that I would like to encode/write it into a text file.
Next, I need to decode the text file and write it into the zip file.
What I am doing wrong in the codes below?
I am getting the errors below.



# Encoding zip to text file
import base64

f = open('xpdf.txt','wb')
x = open('xpdf-tools-win-4.01.01.zip','rb').read()
f.write(base64.b64encode(x))
f.write(b.encode('utf8'))
f.close()


Below is the error for this step:



AttributeError Traceback (most recent call last)
<ipython-input-108-a3559e490128> in <module>
4 x = open('xpdf-tools-win-4.01.01.zip','rb').read()
5 f.write(base64.b64encode(x))
----> 6 f.write(b.encode())
7 f.close()

AttributeError: 'bytes' object has no attribute 'encode'


# Decoding text to zip
import base64

t = open('xpdf1.txt','rb').read()
f = open('xpdf-tools-win-4.01.zip','wb')
f.write(base64.b64decode(f))
f.close()


Below is the error for this step:



TypeError Traceback (most recent call last)
<ipython-input-111-e47fc1159960> in <module>
3 t = open('xpdf1.txt','rb').read()
4 f = open('xpdf-tools-win-4.01.zip','wb')
----> 5 f.write(base64.b64decode(f))
6 f.close()

~Anaconda3libbase64.py in b64decode(s, altchars, validate)
78 in the input result in a binascii.Error.
79 """
---> 80 s = _bytes_from_decode_data(s)
81 if altchars is not None:
82 altchars = _bytes_from_decode_data(altchars)

~Anaconda3libbase64.py in _bytes_from_decode_data(s)
44 except TypeError:
45 raise TypeError("argument should be a bytes-like object or ASCII "
---> 46 "string, not %r" % s.__class__.__name__) from None
47
48

TypeError: argument should be a bytes-like object or ASCII string, not 'BufferedWriter'









share|improve this question




























    0















    I have a zip file that I would like to encode/write it into a text file.
    Next, I need to decode the text file and write it into the zip file.
    What I am doing wrong in the codes below?
    I am getting the errors below.



    # Encoding zip to text file
    import base64

    f = open('xpdf.txt','wb')
    x = open('xpdf-tools-win-4.01.01.zip','rb').read()
    f.write(base64.b64encode(x))
    f.write(b.encode('utf8'))
    f.close()


    Below is the error for this step:



    AttributeError Traceback (most recent call last)
    <ipython-input-108-a3559e490128> in <module>
    4 x = open('xpdf-tools-win-4.01.01.zip','rb').read()
    5 f.write(base64.b64encode(x))
    ----> 6 f.write(b.encode())
    7 f.close()

    AttributeError: 'bytes' object has no attribute 'encode'


    # Decoding text to zip
    import base64

    t = open('xpdf1.txt','rb').read()
    f = open('xpdf-tools-win-4.01.zip','wb')
    f.write(base64.b64decode(f))
    f.close()


    Below is the error for this step:



    TypeError Traceback (most recent call last)
    <ipython-input-111-e47fc1159960> in <module>
    3 t = open('xpdf1.txt','rb').read()
    4 f = open('xpdf-tools-win-4.01.zip','wb')
    ----> 5 f.write(base64.b64decode(f))
    6 f.close()

    ~Anaconda3libbase64.py in b64decode(s, altchars, validate)
    78 in the input result in a binascii.Error.
    79 """
    ---> 80 s = _bytes_from_decode_data(s)
    81 if altchars is not None:
    82 altchars = _bytes_from_decode_data(altchars)

    ~Anaconda3libbase64.py in _bytes_from_decode_data(s)
    44 except TypeError:
    45 raise TypeError("argument should be a bytes-like object or ASCII "
    ---> 46 "string, not %r" % s.__class__.__name__) from None
    47
    48

    TypeError: argument should be a bytes-like object or ASCII string, not 'BufferedWriter'









    share|improve this question
























      0












      0








      0








      I have a zip file that I would like to encode/write it into a text file.
      Next, I need to decode the text file and write it into the zip file.
      What I am doing wrong in the codes below?
      I am getting the errors below.



      # Encoding zip to text file
      import base64

      f = open('xpdf.txt','wb')
      x = open('xpdf-tools-win-4.01.01.zip','rb').read()
      f.write(base64.b64encode(x))
      f.write(b.encode('utf8'))
      f.close()


      Below is the error for this step:



      AttributeError Traceback (most recent call last)
      <ipython-input-108-a3559e490128> in <module>
      4 x = open('xpdf-tools-win-4.01.01.zip','rb').read()
      5 f.write(base64.b64encode(x))
      ----> 6 f.write(b.encode())
      7 f.close()

      AttributeError: 'bytes' object has no attribute 'encode'


      # Decoding text to zip
      import base64

      t = open('xpdf1.txt','rb').read()
      f = open('xpdf-tools-win-4.01.zip','wb')
      f.write(base64.b64decode(f))
      f.close()


      Below is the error for this step:



      TypeError Traceback (most recent call last)
      <ipython-input-111-e47fc1159960> in <module>
      3 t = open('xpdf1.txt','rb').read()
      4 f = open('xpdf-tools-win-4.01.zip','wb')
      ----> 5 f.write(base64.b64decode(f))
      6 f.close()

      ~Anaconda3libbase64.py in b64decode(s, altchars, validate)
      78 in the input result in a binascii.Error.
      79 """
      ---> 80 s = _bytes_from_decode_data(s)
      81 if altchars is not None:
      82 altchars = _bytes_from_decode_data(altchars)

      ~Anaconda3libbase64.py in _bytes_from_decode_data(s)
      44 except TypeError:
      45 raise TypeError("argument should be a bytes-like object or ASCII "
      ---> 46 "string, not %r" % s.__class__.__name__) from None
      47
      48

      TypeError: argument should be a bytes-like object or ASCII string, not 'BufferedWriter'









      share|improve this question














      I have a zip file that I would like to encode/write it into a text file.
      Next, I need to decode the text file and write it into the zip file.
      What I am doing wrong in the codes below?
      I am getting the errors below.



      # Encoding zip to text file
      import base64

      f = open('xpdf.txt','wb')
      x = open('xpdf-tools-win-4.01.01.zip','rb').read()
      f.write(base64.b64encode(x))
      f.write(b.encode('utf8'))
      f.close()


      Below is the error for this step:



      AttributeError Traceback (most recent call last)
      <ipython-input-108-a3559e490128> in <module>
      4 x = open('xpdf-tools-win-4.01.01.zip','rb').read()
      5 f.write(base64.b64encode(x))
      ----> 6 f.write(b.encode())
      7 f.close()

      AttributeError: 'bytes' object has no attribute 'encode'


      # Decoding text to zip
      import base64

      t = open('xpdf1.txt','rb').read()
      f = open('xpdf-tools-win-4.01.zip','wb')
      f.write(base64.b64decode(f))
      f.close()


      Below is the error for this step:



      TypeError Traceback (most recent call last)
      <ipython-input-111-e47fc1159960> in <module>
      3 t = open('xpdf1.txt','rb').read()
      4 f = open('xpdf-tools-win-4.01.zip','wb')
      ----> 5 f.write(base64.b64decode(f))
      6 f.close()

      ~Anaconda3libbase64.py in b64decode(s, altchars, validate)
      78 in the input result in a binascii.Error.
      79 """
      ---> 80 s = _bytes_from_decode_data(s)
      81 if altchars is not None:
      82 altchars = _bytes_from_decode_data(altchars)

      ~Anaconda3libbase64.py in _bytes_from_decode_data(s)
      44 except TypeError:
      45 raise TypeError("argument should be a bytes-like object or ASCII "
      ---> 46 "string, not %r" % s.__class__.__name__) from None
      47
      48

      TypeError: argument should be a bytes-like object or ASCII string, not 'BufferedWriter'






      python-3.x text encoding zip






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 25 at 1:53









      LoicLoic

      7814




      7814






















          0






          active

          oldest

          votes












          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55330374%2fencoding-decoding-b64-zip-file-into-a-text-and-vice-versa-python-3%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55330374%2fencoding-decoding-b64-zip-file-into-a-text-and-vice-versa-python-3%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

          SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

          은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현