且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在pythonanywhere.com上找不到文件

更新时间:2023-11-04 20:27:22

os.path.dirname(__ file __)为您提供了相对路径.在本地服务器上,恰好它对应于正确的路径.在PythonAnywhere上,使用 module_dir 的完整路径.像这样: os.path.abspath(os.path.dirname(__ file __))

This os.path.dirname(__file__) is giving you a relative path. On your local server, it just happens that it corresponds to the correct path. On PythonAnywhere, use the full path for module_dir. Like this: os.path.abspath(os.path.dirname(__file__))