Python file operation Exercise: Obtaining the last access time of a file

Source: Internet
Author: User

#coding =utf-8

Import OS
Import time

File_atime=int (Os.path.getatime (' D:\\a.txt '))
Print "File_atime:", File_atime
Time_arr=time.localtime (File_atime)
print ' Time_arr: ', Time_arr

Print "Regular time:", Time.strftime ('%y-%m-%d%h:%m:%s ', Time_arr)


C:\python27\scripts>python task_test.py
file_atime:1522027881
Time_arr:time.struct_time (tm_year=2018, tm_mon=3, tm_mday=26, tm_hour=9, tm_min=31, tm_sec=21, tm_wday=0, tm_yday=85, tm_isdst=0)
Regular Time:2018-03-26 09:31:21

Python file operation Exercise: Obtaining the last access time of a file

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.