我一直在为一个介绍性python类编写一些代码,当我输入下面显示的代码时,我在扫描字符串文字错误时得到了EOL。有谁知道我在这里做错了什么?
infile2 = open('nasdaq.txt, 'r')
read_text2 = infile2.read()
words2 = read_text2.split()
lowercase_words = []
for word in words2:
lowercase_words.append(word.lower())
word_dict = dict()
for term in lowercase_words:
if term in word_dict:
word_dict[term] += 1
else:
word_dict[term] = 1
infile2.close
答案 0 :(得分:1)
您没有正确引用该文本文件。这样的事情会解决它:
infile2 = open('nasdaq.txt', 'r')