PyCharm在Linux环境下加载文件路径,如果需要写相对路径,那么"./"这种方式会报错,应该写成"../"这种方式。
如调用open()函数:
stopwords_file='../data/stopwords.txt'
stopwords=list()
with open(stopwords_file,mode='r',encoding='utf-8') as f:
for line in f.readlines():
line=line.strip()
stopwords.append(line)
这种情况,不会报错。但是如果绝对路径写成"./",会报路径找不到错误。
如:
stopword_file='./data/stopwords.txt'
或者
stopword_file='/data/wtopwords.txt'