title: Python3: write string into .txt.bz2 file
body: <p>I want to write the join result by two list into the txt.bz2 file(the file name is named by code, not exist at the beginning). like the following form in txt file.</p>
  
  <pre><code>1 a,b,c
  0 d,f,g
  ....... 
  </code></pre>
  
  <p>But there is error. My code is following, please give me hints how to deal with it. Thanks!</p>
  
  <p>import bz2</p>
  
  <pre><code>x = ['a b c', 'd f g', 'h i k', 'k j l']
  y = [1, 0, 0, 1]
  
  with bz2.BZ2File("data/result_small.txt.bz2", "w") as bz_file:
      for i in range(len(y)):
          m = ','.join(x[i].split(' '))
          n = str(y[i])+'\t'+m
          bz_file.write(n)
  </code></pre>
  
  <p>error:</p>
  
  <pre><code>    compressed = self._compressor.compress(data)
  TypeError: a bytes-like object is required, not 'str'
  </code></pre>