import os,time
def createfile(lx = ".xlsx"):
log_path = os.path.dirname(os.path.abspath('.')) + '\\data\\'
t = time.strftime('%Y%m%d%H%M%S', time.localtime(time.time())) #将指定格式的当前时间以字符串输出
suffix = lx # 文件类型
newfile= t + suffix
path = log_path + t + suffix
f = open(path,'w')
print(newfile)
f.close()
return newfile
createfile()
修改成
import os,time
def createfile(lx = ".xls"): #这里修改
log_path = os.path.dirname(os.path.abspath('.')) + '\\data\\'
t = time.strftime('%Y%m%d%H%M%S', time.localtime(time.time())) #将指定格式的当前时间以字符串输出
suffix = lx # 文件类型
newfile= t + suffix
path = log_path + t + suffix
f = open(path,'w')
print(newfile)
f.close()
return newfile
createfile()