python 删除指定路径下的csv文件

来源:互联网 发布:ubuntu安装maven 编辑:程序博客网 时间:2024/05/29 10:20

话不多说,先上代码:

pwd = os.getcwd()  # 获得当前工作目录filePath = 'C:\Users\Administrator\Desktop\Course comments\Number\\' + category# 得到该分类的所有课程file_course_list = os.listdir(filePath)#    print len(file_course_list)# 去掉.csv后缀courses_name = [file_course.split('.')[0] for file_course in file_course_list]for course_name in courses_name:    if course_name not in clean_course:        clean_course.append(course_name)

#删除指定路径的csv文件
        name = os.path.join(course_name+'.csv')        os.remove(os.path.join(filePath,name))        print name

阅读全文
0 0
原创粉丝点击