For a sudden idea: simple to solve with Python is good. Now it's time to fill out the basic function pits needed for this project. The rest is the pit of AI and data presentation.
The pits we met today are:
1, from Excel read the Chinese is garbled
2, Chinese writing MySQL database is garbled
Resolution 1:
The method is actually very simple, just a word:
str = str.encode (' Utf-8 ')
After that, str can display Chinese correctly in both console and variables.
Resolution 2:
The method is also very simple, there is only one sentence:
To connect to the database, you need to specify the database encoding as UTF8, as follows: MySQLdb.connect (port= ' localhost ', user= ' root ', password= ' xxxx ', db= ' xxxxxx ', charset= ' UTF8 ')
Note that the UTF8 here can not be written utf-8, otherwise it will error.
Read and write excel in Python and save it in MySQL