Os.stat () on Windows

What fields are os.stat()filled with dummy values ​​in Windows?

The python document is not clear. In particular, what does st_inoWindows do?

Can someone start an interactive python session on Windows and tell me? I do not have a Windows machine, so I cannot do this.

+5
source share
6 answers

Python 3.1.2 says:

>>> os.stat("C:\\autoexec.bat")
nt.stat_result(st_mode=33279, st_ino=0, st_dev=0, st_nlink=0, st_uid=0, st_gid=0,
st_size=0, st_atime=1150614982, st_mtime=1150614982, st_ctime=1150614982)
+1
source

Here's a test run:

C:\WINDOWS>echo test > test.txt

C:\WINDOWS>python
Python 2.6.5 (r265:79096, Mar 19 2010, 21:48:26) [MSC v.1500 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.stat('test.txt')
nt.stat_result(st_mode=33206, st_ino=0L, st_dev=0, st_nlink=0, st_uid=0, st_gid=
0, st_size=7L, st_atime=1299861919L, st_mtime=1299861919L, st_ctime=1299861919L)

>>>
+2
source

Python 3.3.4

>>> os.stat('.')
nt.stat_result(st_mode=16895, st_ino=1407374883604316, st_dev=0, st_nlink=1, st_uid=0,
st_gid=0, st_size=4096, st_atime=1392476826, st_mtime=1392476826, st_ctime=1392374365)

st_ino.

+2

Python 3:

>>> os.stat( r'C:\Users\poke\Desktop\test.txt' )
nt.stat_result(st_mode=33206, st_ino=0, st_dev=0, st_nlink=0, st_uid=0, st_gid=0, st_size=252, st_atime=1299861949, st_mtime=1298245084, st_ctime=1299861949)

- ?

0

st_ino, st_dev, st_nlink, st_uid st_gid Windows 7 1 (SP1) Python 2.7.11:

import os; os.stat('Desktop\test.txt')
nt.stat_result(st_mode=33206, st_ino=0L, st_dev=0L, st_nlink=0, st_uid=0, st_gid=0, st_size=293L, st_atime=1448376581L, st_mtime=1451782006L, st_ctime=1448376581L)

, , Windows 7 1 (SP1) Python 3.5.1:

import os; os.stat('Desktop\test.txt')
os.stat_result(st_mode=33206, st_ino=17732923532870243, st_dev=2289627604, st_nlink=2, st_uid=0, st_gid=0, st_size=293, st_atime=1448376581, st_mtime=1451782006, st_ctime=1448376581)

Python os.stat Windows, , - /- . st_size, st_atime, st_mtime, st_ctime . , , Python, , Windows , , .

0

os.stat python 3.4.

,

import os


myPath = os.path.expanduser("~")
os.chdir(myPath)

files = os.listdir()

for file in files:
    info = os.stat(file)
    print ("{0:>20} {1:>8}".format(file, info.st_size))
-1

All Articles