[Tutor] file questions

Alan Gauld alan.gauld at btinternet.com
Wed Nov 25 11:04:59 CET 2009


"spir" <denis.spir at free.fr> wrote

> 1) encoding guess
> How can python do that?

I'll let someone else try that one :-)

> 2) time stamp
> How to read it (found no attr in "file" type)? (If possible in platform 
> independant manner, and as datetime object.)

Which timestamp? There are several.

To read them use the os.path functions getctime() and getmtime() etc.
You can also use the os.stat function to return a tuple of file 
characteristics
including creation, modification and last open times.

See my tutorial topic on Using the OS to see some examples.


HTH,

-- 
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/ 




More information about the Tutor mailing list