python - How to convert a stat output to a unix permissions string -
if run os.stat(path)
on file , take st_mode
parameter, how there string this: rw-r--r--
known unix world?
since python 3.3 use stat.filemode
:
in [7]: import os, stat in [8]: print(stat.filemode(os.stat('/home/soon/foo').st_mode)) -rw-r--r-- in [9]: ls -l ~/foo -rw-r--r-- 1 users 0 jul 23 18:15 /home/soon/foo
Comments
Post a Comment