我换了,一样报错
代码及报错代码#-*-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[key]={}
for i in traning_data:
if i in data[key]:
data[key][i]+=1
else:
data[key][i]=1
save()
returner=None
def look(passage):
global returner
a=[0]*len(data)
for i in passage:
count=0
for x in data:
if i in x:
a[count]+=data[x][i]
count+=1
returner=[x/sum(a) for x in a]
result()
def result():
count=0
Max=returner[0]
title='.....我也不知道'
for z in data:
print('这篇文章是%s类文章的可能性是%.2f%'%(z,returner[count]))
if returner[count]>Max:
Max=returner[count]
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
|