码迷,mamicode.com
首页 > 编程语言 > 详细

Python search directories

时间:2015-09-14 20:59:55      阅读:243      评论:0      收藏:0      [点我收藏+]

标签:

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.

Python search directories

标签:

原文地址:http://www.cnblogs.com/ch3cooh/p/python-search-directories.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!