摘自:http://www.jb51.net/article/60641.htm #!/usr/bin/env python import glob import os os.chdir(“./”) for file in glob.glob(“*.py”): print file print “#######Another One##########” for file in os.listdir(“./”): if file.endswith(“.py”): print file print