import os,sys for root,dirs,files in os.walk(sys.argv[1]): for name in files: print(os.path.join(root,name)) for name in dirs: print(os.path.join(root,name))
要写sys.argv[1],
python filename 参数
这里的参数是个路径