a={'a':{'b':{'c':{'d':'e'}},'f':'g'},'h':'i'} def show(myMap): for str in myMap.keys(): secondDict=myMap[str] print str if type(myMap[str]).__name__=='dict': for key in secondDict.keys(): if type(secondDict[key]).__name__=='dict': print key show(seco
#coding: utf-8 """ this programe is to clear driverlog below this dir __author__:the_new_one """ import os, traceback #查找文件名中包含关键词的文件 def search_dir(s, path=os.path.abspath('.'),files = []): try: for x in os.listdir(path): pa
#!/usr/bin/python dict={"a":"apple","b":"banana","o":"orange"} print "##########dict######################" for i in dict: print "dict[%s]=" % i,dict[i] print "##########
dict={"a":"apple","b":"banana","o":"orange"} print "##########dict######################" for i in dict: print "dict[%s]=" % i,dict[i] print "###########items############
Python作为一种脚本语言.其很适合文件级的各种操作.以下的代码能够批量删除指定目录下的所有特定类型(CSV类型)的文件. import sys, csv , operator import os import glob for i in range(0, 20): path = "C:\\Python34\\Folder_" + str(i) for infile in glob.glob( os.path.join(path, '*.csv') ): os.remove(infi
在使用集合的过程中,我们经常会有遍历集合元素,删除指定的元素的需求,而对于这种需求我们往往使用会犯些小错误,导致程序抛异常或者与预期结果不对,本人很早之前就遇到过这个坑,当时没注意总结,结果前段时间又遇到了这个问题,因此,总结下遍历集合的同时如何删除集合中指定的元素: 1.错误场景复原 public class ListRemoveTest { public static void main(String[] args) { List<User> users = new ArrayList&l