I am using Python 2.7 to read data from a MySQL table. In MySQL, the name is as follows:
Garasa, Angel.
But when I print it in Python, the output
Garasa, ngel
The character set name in MySQL is utf8. This is my Python code:
import MySQLdb
connection = MySQLdb.connect
(host="localhost",user="root",passwd="root",db="jmdb")
cursor = connection.cursor ()
cursor.execute ("select * from actors where actorid=672462;")
data = cursor.fetchall ()
for row in data:
print "IMDB Name=",row[4]
wiki=("".join(row[4]))
print wiki
I tried to decode it, but I get an error, for example:
UnicodeDecodeError: codec 'utf8' cannot decode byte 0xc1 at position 8: invalid start byte
I read about decoding and UTF-8, but could not find a solution.
source
share