标签:
1. Search current directory
2. Search PYTHONPATH
3. Search standard library directories
4. Search directories specified in .pth files (!!!)
5. Search lib\site-packages directory and third-party extensions
Let‘s see how 4 works.
This is my toy module
# d:\code\nonexsistent\void.py import os print(‘You are now at %r‘%os.getcwd())
And this is the .pth file named "silly_search_directory.pth" I placed at "C:\python34\"
d:/code/nonexistent
Importing the toy module from the interactive shell
Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 24 2015, 22:43:06) [MSC v.1600 32 bit (Intel)] on win32 Type "copyright", "credits" or "license()" for more information. >>> import void You are now at ‘C:\\Python34‘ >>>
So you see the .pth file do works and the output is interesting.
标签:
原文地址:http://www.cnblogs.com/ch3cooh/p/python-search-directories.html