My function returns a tuple
which is then assigned to a variable x and appended to a list.
x = (u'string1', u'string2', u'string3', u'string4')
Use a nested list comprehension:
encoded = [[s.encode('utf8') for s in t] for t in resultsList]
This produces a list of lists containing byte strings of UTF-8 encoded data.
If you were to print these lists, you'll see Python represent the contents of the Python byte strings as Python literal strings; with quotes and with any bytes that aro not printable ASCII codepoints represented with escape sequences:
>>> l = ['Kaiserstra\xc3\x9fe'] >>> l ['Kaiserstra\xc3\x9fe'] >>> l 'Kaiserstra\xc3\x9fe' >>> print l Kaiserstraße
This is normal as Python presents this data for debugging purposes. The
\x9f escape sequences represent the two UTF-8 bytes C39F (hexadecimal) that are used to encode the small ringel-es character.