import osprint os.path.abspath(__file__) #返回脚本名称(包含全路径),如C:\Django\workplace\sf\sinfors\tests5.pyprint os.path.dirname(os.path.abspath(__file__)) #返回脚本所在目录,如C:\Django\workplace\sf\sinforsprint os.path.dirname(os.path.dirname(os.path.abspath(__file__))) #返回脚本所在目录的父目录,如C:\Django\workplace\sf
import oslogf = os.path.join(os.getcwd(),'log.log')fw = open(logf,'a')fw.write('aa')fw.close()