I have a for loop inside which I print each iterations in the loop and gives a output that is in the format of ls-lrt . I would like to create a dictionary out of this with key as name of file and value as the timestamp.
for attr in sftp.listdir_attr('/abc'):
... print attr
...
-rwxr-xr-x 1 7202711 7201853 5759 01 Mar 12:49 .nfs0000000615c569f500000004
-rw-r--r-- 1 7202711 7201853 62394 26 Sep 2017 1.java
-rwxr-xr-x 1 7202711 7201853 5009 20 Aug 2017 a.sh
-rwxr-xr-x 1 7202711 7201853 2201 15 Oct 2017 adt.sh
drwxr-xr-x 1 7202711 7201853 282 09 Jun 2017 backup
-rwxr-xr-x 1 7202711 7201853 1384 27 Jul 2017 ob.sh
If I do a
type(attr)
it gives me
<class 'paramiko.sftp_attr.SFTPAttributes'>
So the dict should be like (the date and time format needs to be standardized)
{'.nfs0000000615c569f500000004':'01 Mar 12:49',
'1.java':'26 Sep 2017',..............etc}