Discuss / Python / 练习1

练习1

Topic source

#1 Created at ... [Delete] [Delete and Lock User]
"""利用os模块编写一个能实现dir -l输出的程序。"""import osfrom datetime import datetimefor x in os.listdir('.'):    s = os.path.getsize(x)    d = '     '    if os.path.isdir(x):        d = '<DIR>'        s = '     '    print(datetime.fromtimestamp(os.path.getctime(x)).strftime('%Y-%m-%d %H:%M'), ' ', d, ' ', s, ' ', x)

  • 1

Reply