摘要: 原文地址:http://www.4ucode.com/Study/Topic/1477794python __file__ 与argv[0]在python下,获取当前执行主脚本的方法有两个:sys.argv[0]和__file__。sys.argv[0]获取主执行文件路径的最佳方法是用sys.argv[0],它可能是一个相对路径,所以再取一下abspath是保险的做法,像这样:import os,sysdirname, filename = os.path.split(os.path.abspath(sys.argv[0]))print "running from", di 阅读全文
posted @ 2012-02-20 17:24 一只梨 阅读(666) 评论(0) 推荐(0) 编辑