用来实验的目录如下:
附上代码:
# _*_ coding:utf-8 _*_
import os
__author__ = 'admin'
def files_name(dirpath):
for root, dirs, files in os.walk(dirpath):
return files
namelist = files_name(r"D:\360浏览器\360se6\User Data")
for name in namelist:
print(name)
运行结果如下: