#-*-Coding:utf-8-*-
Import Codecs
#f1 = Codecs.open ("D:\\python_code\\bayes\\data\\label.txt", ' R ', ' Utf-8 ')
F1 = open ("D:\\python_code\\bayes\\data\\label.txt")
List1 = [' Taste ', ' logistics ', ' appearance ', ' packaging ', ' Price/performance ', ' quality ', ' efficacy ', ' price ', ' giveaway ', ' service ']
List2 = []
For line in F1:
line = Line.strip ()
List2.append (line)
Print List1
Print List2
For L1 in List1:
#l1 = L1.decode ("Utf-8")
Print L1,
If L1 in List2:
Print True
Else
Print False
Label.txt:
Taste
Logistics
Appearance
Packaging
Price
Effect
Price
Gifts
Service
List1: [' \xe5\x91\xb3\xe9\x81\x93 ', ' \xe7\x89\xa9\xe6\xb5\x81 ', ' \xe5\xa4\x96\xe8\xa7\x82 ', ' \xe5\x8c\x85\xe8\xa3\ X85 '
List2: [' \xef\xbb\xbf\xe5\x91\xb3\xe9\x81\x93 ', ' \xe7\x89\xa9\xe6\xb5\x81 ', ' \xe5\xa4\x96\xe8\xa7\x82 ', ' \xe5\x8c\ X85\xe8\xa3\x85 '
Data read from the beginning of the file with the \XEF\XBB\XBF prefix
Python Coding issues