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.
精彩评论