python 获取文件夹下指定后悔的文件名
import os
import pandas
def file_name(file_dir):
L = []
for root, dirs, files in os.walk(file_dir):
for file in files:
if os.path.splitext(file)[1] == '.py':
L.append(file[:-3])
return L
name = file_name('/home/xuefliang/PycharmProjects/untitled/')
print(type(name))
# df=pandas.DataFrame(name)
# df.to_csv('/home/xuefliang/filename.csv')
import pandas
def file_name(file_dir):
L = []
for root, dirs, files in os.walk(file_dir):
for file in files:
if os.path.splitext(file)[1] == '.py':
L.append(file[:-3])
return L
name = file_name('/home/xuefliang/PycharmProjects/untitled/')
print(type(name))
# df=pandas.DataFrame(name)
# df.to_csv('/home/xuefliang/filename.csv')
评论
发表评论