-
Notifications
You must be signed in to change notification settings - Fork 9
你好,我运行你的代码出现了一个错误 #3
Copy link
Copy link
Open
Description
for line in file:
line = line.lower().encode('utf-8')
words = line.split()
for word in words:
word = word.translate(None, string.punctuation)
if word != '':
allWords.append(word)
这段代码,的word.translate(None, string.punctuation)一句,报TypeError: a bytes-like object is required, not 'str'这个错误。在网上查了下,说可能是py3.5的问题,加上decode后,又报了TypeError: translate() takes exactly one argument (2 given)错误。。。请问,该怎么破?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels