Discuss / Python / 第一题

第一题

Topic source

本地的Yoyo

#1 Created at ... [Delete] [Delete and Lock User]

import time

import os

import sys

def dirl(dir):

    try:

        for x in os.listdir(dir):

            y=os.path.join(dir,x)

            if os.path.isfile(y):

                print (time.strftime("%m-%d-%Y %X",time.localtime(os.path.getctime(y))),os.path.getsize(y),  x.lower())

            elif os.path.isdir(y):

                #dirl (y) #go through subdir if needed

                print (time.strftime("%m-%d-%Y %X",time.localtime(os.path.getctime(y))),'<DIR>',  x.lower())

    except Exception as e:

        print (e)

dirl ('.')

dirl(r'C:\Windows')


  • 1

Reply