title: Python 3 - xlwt save Workbook error
body: <p>I'm writing a small program in Python 3.6 that reads an excel file and then modifies the format of a cell. I want multiple formats within the same cell so I'm using <code>xlwt</code> with <code>write_rich_text</code>:</p>
  
  <pre><code>import xlrd
  import xlwt
  from xlutils.copy import copy
  
  col = 0
  row = 0
  
  rb = xlrd.open_workbook('test.xls', formatting_info=True)
  
  r_sheet = rb.sheet_by_index(0) 
  text_cell = r_sheet.cell_value(row, col)
  
  book = copy(rb)
  first_sheet = book.get_sheet(0)
  
  font1 = xlwt.easyfont('struck_out true, color_index red')
  font2 = xlwt.easyfont('color_index green')
  
  seg1 = (text_cell[0:10], font1)
  seg2 = (text_cell[10:], font2)
  
  
  first_sheet.write_rich_text(row, col, [seg1, seg2])
  
  book.save('test.xls')
  </code></pre>
  
  <p>Everything works fine up to the point of writing on to the excel file but then I get the error <code>TypeError: must be str, not bytes</code> when saving the Workbook. </p>
  
  <p>Full error:</p>
  
  <pre><code>File "test.py", line 91, in &lt;module&gt;
  book.save('test.xls')
  
  File "C:\Users\...\AppData\Local\Continuum\Anaconda2\envs\py36\lib\site-packages\xlwt\Workbook.py", line 710, in save
  doc.save(filename_or_stream, self.get_biff_data())
  
  File "C:\Users\...\AppData\Local\Continuum\Anaconda2\envs\py36\lib\site-packages\xlwt\Workbook.py", line 674, in get_biff_data
  shared_str_table   = self.__sst_rec()
  
  File "C:\Users\...\AppData\Local\Continuum\Anaconda2\envs\py36\lib\site-packages\xlwt\Workbook.py", line 636, in __sst_rec
  return self.__sst.get_biff_record()
  
  File "C:\Users\...\AppData\Local\Continuum\Anaconda2\envs\py36\lib\site-packages\xlwt\BIFFRecords.py", line 79, in get_biff_record
  self._add_rt_to_sst(s)
  
  File "C:\Users\...\AppData\Local\Continuum\Anaconda2\envs\py36\lib\site-packages\xlwt\BIFFRecords.py", line 108, in _add_rt_to_sst
  rt_str, rt_fr = upack2rt(rt, self.encoding)
  
  File "C:\Users\...\AppData\Local\Continuum\Anaconda2\envs\py36\lib\site-packages\xlwt\UnicodeUtils.py", line 86, in upack2rt
  fr += pack('&lt;HH', offset, fontx)
  
  TypeError: must be str, not bytes
  </code></pre>
  
  <p>I've been searching for a solution to this problem but the answers there don't seem to solve my problem:</p>
  
  <p><a href="https://stackoverflow.com/questions/43725686/xlwt-book-save-typeerror-must-be-str-not-bytes">xlwt book.save TypeError: must be str, not bytes</a></p>
  
  <p><a href="https://stackoverflow.com/questions/41616591/python-code-not-able-to-write-into-xls">Python code, not able to write into xls</a></p>
  
  <p>Then I found that this issue could be related to the way strings are handled in Python 3 vs Python 2 and that I might be getting a byte string somewhere that is causing the error.</p>
  
  <p>I looked at the type of <code>text_cell</code> and is <code>str</code>, I tried ommiting the font in <code>seg1</code> and <code>seg2</code> but it still didn't work.
  Finally I ran this same script on Python 2.7 and it worked! </p>
  
  <p>The bad news is that I need the code to work in Python 3 since the server where this would run only has Python 3 and cannot be changed.</p>
  
  <p>Anyone has a clue of what might be causing the issue?</p>