更新时间: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__))