Python小知识

1、获取脚本所在目录

if getattr(sys, 'frozen', False):
current_ini = os.path.join(os.path.dirname(sys.executable), 'amazon.ini')
print 'execute type: {}, current ini: {}'.format('exe', current_ini)
else:
current_ini = os.path.join(os.path.split(os.path.realpath(__file__))[0], 'amazon.ini')
print 'execute type: {}, current ini: {}'.format('script', current_ini)
posted @ 2016-12-21 21:06  大山山  阅读(334)  评论(0编辑  收藏  举报