python中__file__

用__file__ 来获得脚本所在的路径,比如文件在/root下

cat tee

#!/usr/bin/env python
print __file__              #得到相对路径tee

——————————————————————————————————————

import os
#!/usr/bin/env python
print  os.path.realpath(__file__)                        #得到绝对路径/root/tee

 

posted on 2013-06-17 16:01  语辰  阅读(778)  评论(0编辑  收藏  举报