Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在开发 Django 应用程序时,sys.path应该包含什么?包含项目的目录,或项目的目录,或两者兼而有之?
sys.path
sys.path应该并且将拥有项目的目录。根据您的设置,它还可能包含包含项目的目录。
但是,如果这个问题背后的动机是确保可以找到某些文件,那么您应该注意这sys.path就像一个普通列表并且可以附加到。因此,您可以添加一个新位置,sys.path如下所示:
sys.path.append('/home/USER/some/directory/')
在哪里可以找到您的文件。
希望这可以帮助
据我所知,这只是个人品味的问题。我选择包含项目的目录,但这只是我的偏好。