In one of my python program(python 2.7), I need to process some chinese characters:
I have a file A.txt, it has two columns: "name" and "score", the "name" column can be valued some chinese strings, and score is an int number values between 1 and 10. A.txt is encoded in GBK, which is a chinese character encoding.
I insert every row of A.txt into my mysql table tb_name_score, it has three columns: ID, NAME, SCORE, and its NAME column's encoding is latin1_swedish_ci
now, I have another file names B.txt, which has two columns too, "name" and "score", and I need to update the tb_name_score's SCORE column according to B.txt. B.txt is also encoded in GBK
so, I traverse B.txt, read a line and use it's "name" value to compare with the records in tb_name_score.NAME, if they are equal, then I update tb_name_score.SCORE. However, although the "name" column of the line in B.txt is the same chinese string with the value in tb_name_score.NAME, the "=" returns false, I just can't update the table. Anybody can help? thanks!
hope it helps: