1. 程式人生 > >python 獲取程式所在路徑再寫log

python 獲取程式所在路徑再寫log


import os
localDir=os.path.dirname(__file__)
path = localDir + "/log"
now1 = datetime.datetime.now()
nownow = now1.strftime("%Y-%m-%d-%H-%M")
strnnn = path + "/"+str(nownow) +".log"
logging.basicConfig(filename=strnnn, level=logging.DEBUG)