Closed Eurus-Holmes closed 6 years ago
Solved! The Unicode string in python3 is the default format (that is, str type), ASCII-encoded string (which is the bytes type, bytes type contains byte values, in fact, not a string, python3 and byte array byte array type) to be in front The addition operator b or B; python2 is the opposite, the ASCII encoding string is the default, the Unicode string is preceded by the operator u or U...
您好,运行IMDB_Classifier_MLP.py时报错:
Using TensorFlow backend. Traceback (most recent call last): (25000, 3) File "/Users/chenfeiyang/PycharmProjects/Sentiment_analysis_IMDB/IMDB_Classifier_MLP.py", line 45, in
texts.append(clean_str(text.get_text().encode('ascii','ignore')))
File "/Users/chenfeiyang/PycharmProjects/Sentiment_analysis_IMDB/IMDB_Classifier_MLP.py", line 32, in clean_str
string = re.sub(r"\", "", string)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/re.py", line 191, in sub
return _compile(pattern, flags).sub(repl, string, count)
TypeError: cannot use a string pattern on a bytes-like object
请问是为什么呢?