python读取中文目录出现乱码

Python010

python读取中文目录出现乱码,第1张

先对路径进行unicode处理,然后再打开。举例:

inpath = 'E:\MyProject\SVN_Project\Drawingboard_local\model\mydata\input\production\示波器\0.htm'

uipath = unicode(inpath, "utf8")

然后用"uipath"经过编码后的路径去open()即可:

fin = open(uipath)

 解决方法为:

创建数据表时指定charset=utf8,如:

use hongxiudb

create table if not exists hongxiu(

name text,

author text,

intro text

)engine=InnoDB default charset=utf8