file_path = sys.path[0]+'\\students.xls' #sys.path[0]获取当前路径,students.xls为要写入的excel表 f = xlwt.Workbook(encoding='utf-8', style_compression=0) #新建一个excel sheet = f.add_sheet('sheet1') #新建一个sheet pathDir = os.listdir(sys.path[0]) #文件创建在当前目录中,用来获...
Python小记-- 读取当前目录下所有文件名 #-*- coding: utf-8 -*-importosdeffile_name(file_dir): list= []## 空列表forroot, dirs, filesinos.walk(file_dir,topdown=True):fornameinfiles: list.append(name) with open("SelectAllFiles.txt","w") as f:foriteminlist: f.write(item+'\n') ...