# coding=utf-8
# @author:Damon Qu
# @contact:qufengw@126.com
# @date:2018/5/23
import os
'''
获取指定目录下所有文件名,并按格式写入指定文件
'''
def file_name(dir_path, target_file):
f = open(target_file, 'w')
count = 0
for file in os.listdir(dir_path):
if os.path.isfile(dir_path + '/' + file):
count += 1
f.write("'%s'\n" % file)
f.close()
print("write over, the count of files is: %d" % count)
dir_path = input("enter dir path: ")
target_file = input("enter target file name: ")
file_name(dir_path, target_file)
获取指定目录下所有文件名,并按格式写入指定文件
最新推荐文章于 2022-12-09 15:29:35 发布