python之对指定目录文件夹的批量重命名 import os,shutil,string dir = "/Users/lee0oo0/Documents/python/test" #指定的目录 for i in os.listdir(dir): #遍历指定目录的文件 newfile = i.replace('a','b') # 替换 oldname = dir +'/'+str(i) newname = dir +'/'+str(newfile) shutil.move(oldnam
在JavaScript里可以结合for循环和splice来删除数组指定的元素.但是要注意删除元素后,数组索引会发生改变 示例 var arr = ["a","b","c","a",'a',"b"]; var ele = "a"; for(var i = 0; i < arr.length; ) { if(arr[i] == ele) { arr.splice(i, 1);