import os
import datetime
for x in os.listdir('.'):
mtime = datetime.datetime.fromtimestamp(os.path.getmtime(x)).strftime('%Y-%m-%d %H:%M:%S')
dir_status = '<DIR>' if os.path.isdir(x) else ''
size = os.path.getsize(x) if not os.path.isdir(x) else ''
print('%10s\t%10s\t%10s\t%-10s' % (mtime, dir_status, size, x))
云影夜风_843
import os import datetime for x in os.listdir('.'): mtime = datetime.datetime.fromtimestamp(os.path.getmtime(x)).strftime('%Y-%m-%d %H:%M:%S') dir_status = '<DIR>' if os.path.isdir(x) else '' size = os.path.getsize(x) if not os.path.isdir(x) else '' print('%10s\t%10s\t%10s\t%-10s' % (mtime, dir_status, size, x))