#coding=utf-8# -*- coding: utf-8 -*-import osimport sysreload(sys) sys.setdefaultencoding('utf-8') def GetFileList(dir, fileList): newDir = dir if os.path.isfile(dir): fileList.append(dir.decode('gbk')) elif os.path.isdir(dir): for s in os.listdir(di…
#方法1:使用os.listdir import os for filename in os.listdir(r'c:\\windows'): print filename #方法2:使用glob模块,可以设置文件过滤 import glob for filename in glob.glob(r'c:\\windows\\*.exe'): print filename #方法3:通过os.path.walk递归遍历,可以访问子文件夹 import os.path def processDire…
参考方法: import os path = r'C:\Users\Administrator\Desktop\file' for filename in os.listdir(path): print(os.path.join(path,filename))os.listdir() #只遍历当前目录os.walk() #遍历当前目录下以及各个子目录…
生成器迭代器+压缩文件 readme的规范 1软件定位,软件的基本功能2运行代码的方法:安装环境,启动命令3简要的使用说明4代码目录结构说明,更详细点可以说明软件的基本原理5常见问题说明 ======================================================== 列表生成器 [i*2 for i in range(10)] #开头的可为函数也可为方程 已经在内存中生成 存在并可调用 ======================================…
#自定义函数: import ospath="D:\\Temp_del\\a"def gci (path): """this is a statement""" parents = os.listdir(path) for parent in parents: child = os.path.join(path,parent) #print(child) if os.path.isdir(child): gci(child)…
In file included from greenlet.c:5:0: greenlet.h:8:20: 致命错误: Python.h:没有那个文件或目录 编译中断. error: Setup script exited with error: command 'gcc' failed with exit status 1 解决方法是安装python-dev,这是Python的头文件和静态库包: sudo apt-get install python-dev 如果这个python-dev无…