python实现读取指定目录下的文件,并放入到一个数组中

python实现读取指定目录下的文件,并放入到一个数组中

我想用python实现,寻找制定的目录,并在该目录中把所有文件列出来并且放入到一个数组中,我要怎么实现?

我的脚本是这样的,写了一点,不是太好刚刚接触python!
#!/usr/bin/python
import os
import time
import string

sdir=”/root/python”
sfile=os.listdir(sdir)
for ssfile in sfile:
print ssfile
build=time.ctime(os.stat(sdir).st_mtime)
print “the file date was ‘%s'” % build

那为大侠能帮我修改下!

发表评论