Обсуждение: How to correct this encoding/decoding issue with lists?

Поиск
Список
Период
Сортировка

How to correct this encoding/decoding issue with lists?

От
Federico Leoni
Дата:
On a python script I have:

cur.execute(
    "SELECT product_template.name FROM public.pos_order_line,
public.product_template "
    "WHERE pos_order_line.product_id = product_template.id AND
pos_order_line.order_id >= 338 "
    "ORDER BY pos_order_line.id DESC;")
checkname = cur.fetchone()[0]
if checkname.startswith('#'):
    nametmp = checkname
    print checkname, nametmp

In this case the print output is ok:

# + Orégano # + Orégano

Process finished with exit code 0

But if I create a list for nametmp (and is what I need) I get:

    nametmp.insert(0, checkname)
    print checkname, nametmp

# + Orégano ['# + Or\xc3\xa9gano']

Process finished with exit code 0
I'm in Brazil, then my normal encoding should be latin1 but even if I put

# -*- coding: utf-8 -*-

at the start of my .py the result is the same. How can I resolve this issue?

Thanks.

Federico