开发者

Updating a utility to show the date last modified

开发者 https://www.devze.com 2023-03-13 04:46 出处:网络
I am creatingSIMPLE LOG FILE UT开发者_如何学编程LITY gui using python. Each time I run the program, the source file is copied to the destination file and the source file is deleted. When the utility i

I am creating SIMPLE LOG FILE UT开发者_如何学编程LITY gui using python. Each time I run the program, the source file is copied to the destination file and the source file is deleted. When the utility is started I want the display to say "The Log file was last updated (date goes here)". I have created a function named modification() using os.path.getmtime. How do I use this function to display the date?


You can find the answers on the Python docs :

The getmtime function (http://docs.python.org/library/os.path.html#os.path.getmtime) returns the number of seconds

Thanks to the Time module (http://docs.python.org/library/time.html), you can convert the number you get into local time (localtime()) or UTC time (with gmtime()).

Then, you just have to display it with your GUI toolkit as Dhaivat Pandya pointed out.

Regards,

Max


Make it return the date as a string, and then display it with your GUI toolkit.

0

精彩评论

暂无评论...
验证码 换一张
取 消