莫名其妙的字符解析错误
错误信息:'unicode error 'unicodeescape'codec can't decode bytes in position 2-3 : truncated\UXXXXX escape
代码:
from pickle import dump,loads
data={}
def get():
global data
file=open('C:\Users\中维电器维修\Desktop\训练记忆.ple','rb')\
data=loads(file.read())
file.close()
def save():
global data
file=open('C:\Users\中维电器维修\Desktop\训练记忆.ple','wb')
dump(data,data)
file.close()
def traning_saves(traning_data,key):
global data
data={}
for i in traning_data:
if i in data:
data+=1
else:
data=1
save()
returner=None
def look(passage):
global returner
a=*len(data)
for i in passage:
count=0
for x in data:
if i in x:
a+=data
count+=1
returner=
result()
def result():
count=0
Max=returner
title='.....我也不知道'
for z in data:
print('这篇文章是%s类文章的可能性是%.2f%'%(z,returner))
if returner>Max:
Max=returner
title=z
print('综上所述,这篇文章是%s类文章'%z)
你这是干什么了获得的错误信息,你的主程序呢? 可以试着换一个编译器,因为显示是编码错误。建议使用pycharm。不会的话请见【萌新使用 PyCharm 必看】PyCharm 基础使用手册 我换了,一样报错
代码及报错代码
#-*-conding:utf-8-*-
from pickle import dump,loads
data={}
def get():
global data
file=open('C:\Users\中维电器维修\Desktop\训练记忆.ple','rb')
data=loads(file.read())
file.close()
def save():
global data
file=open('C:\Users\中维电器维修\Desktop\训练记忆.ple','wb')
dump(data,data)
file.close()
def traning_saves(traning_data,key):
global data
data={}
for i in traning_data:
if i in data:
data+=1
else:
data=1
save()
returner=None
def look(passage):
global returner
a=*len(data)
for i in passage:
count=0
for x in data:
if i in x:
a+=data
count+=1
returner=
result()
def result():
count=0
Max=returner
title='.....我也不知道'
for z in data:
print('这篇文章是%s类文章的可能性是%.2f%'%(z,returner))
if returner>Max:
Max=returner
title=z
print('综上所述,这篇文章是%s类文章'%z)
C:\ProgramData\Anaconda3\python.exe C:/Users/中维电器维修/Desktop/判断文章.py
File "C:/Users/中维电器维修/Desktop/判断文章.py", line 6
file=open('C:\Users\中维电器维修\Desktop\训练记忆.ple','rb')
^
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape
Process finished with exit code 1
好像又能运行了,谢谢
页:
[1]