unicode0.py 422 B

123456789101112
  1. #!/usr/bin/env python
  2. import xlwt
  3. # Strings passed to (for example) Worksheet.write can be unicode objects,
  4. # or str (8-bit) objects, which are then decoded into unicode.
  5. # The encoding to be used defaults to 'ascii'. This can be overridden
  6. # when the Workbook instance is created:
  7. book = xlwt.Workbook(encoding='cp1251')
  8. sheet = book.add_sheet('cp1251-demo')
  9. sheet.write(0, 0, '\xce\xeb\xff')
  10. book.save('unicode0.xls')