python 打包
我的程序没打包之前运行的很好,但是打包后就不能运行了,下面是记事本里面写的错误
Traceback (most recent call last):
File "ionogram_measure.py", line 5394, in OnFindMe
path1=os.path.join(t2,b)
File "ntpath.pyc", line 108, in join
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe9 in position 26: ordinal not in range(128)
下面是部分代码:
t=open('%s\\DBS\\configuration.txt'%path0.decode('utf-8'),'w')
t1=self.Plateb.GetValue().encode('utf-8')
t2=self.Plateb2.GetValue().encode('utf-8')
t3=self.choice10.GetStringSelection().encode('utf-8')
t4=self.choice12.GetStringSelection().encode('utf-8')
t5=self.choice11.GetStringSelection().encode('utf-8')
t6=self.choice13.GetStringSelection().encode('utf-8')
t7=self.Plateb1.GetValue().encode('utf-8')
s1=self.choice14.GetStringSelection()
y=['是'.decode('utf-8'),'否'.decode('utf-8')]
if s1==y[0]:
t8='1'
else:
t8='0'
#在输出路径下创建文件夹
l=os.listdir(t1.decode('utf-8'))
a=l[0]
b=a[0:8]
path1=os.path.join(t2,b)
value=os.path.exists(path1.decode('utf-8'))
if value==False:
os.mkdir(path1)
path11=path1.decode('utf-8')+'\\'+'图片'.decode('utf-8')
path12=path1.decode('utf-8')+'\\'+'日报'.decode('utf-8')
t.write('%s'%t1)
t.write('\n%s'%path1)
这部分代码经常出错,往记事本写path1的时候以前打包也报过错,而且我还觉得上面有一部分读记事本数据的程序打包后也不能读取,求高数指点
[解决办法]
文件的编码格式也设成utf8的