我是python新手,在这方面遇到了一些问题。 我想用python编写一个脚本,它包含两个输入: 1.目录的路径 2.要删除的文件扩展名
如果用户键入要删除的路径和扩展名,那么我希望用户键入的文件扩展名保存在列表中,当解释器读取文件时,它会自动删除扩展名文件
代码如下:
import os
Ext_list = []
path=raw_input('Enter the path for Scanning : ')
while True:
x = raw_input('Enter the extension: ')
if x == ' ':
break
Ext_list.append(x)
for (path, subdirs, filesnames) in os.walk(path):
if filesnames is (x):
os.remove(filesnames)
使用这个,当然你必须修改它
它将输出具有该扩展名的文件数组。然后呢
相关问题 更多 >
编程相关推荐