2

我开始使用 Sublime Text 2 和 REPL 并遇到了一些问题。当我运行文件时,它告诉我文件 du 不存在。如果脚本是直接从终端构建的,它就可以完美运行。

代码

def stopwords(text):
    with open('danish', 'rU') as f:
        for line in f:
            text = text.replace(' '+line.strip()+' ', "")
    return text

日志

IOError: [Errno 2] No such file or directory: 'danish'

我尝试过类似的东西os.chdir(os.path.dirname(os.path.abspath(sys.argv[0]))) reload(sys)__file__但它们不起作用。

任何想法为什么__file__在通过 Sublime Text 2 REPL 运行或文件存储在哪里时不起作用?

4

0 回答 0