Using Anaconda to install Python HDFs package Python-hdfs 2.1.0 Package
From HDFs Import *
Import time
Client = Client ("http://192.168.56.101:50070")
ll = client.list ('/home/test ', status=true)
For I in LL:
table_name = i[0] #表名
table_attr = i[1] #表的属性
#修改时间1528353247347, 13 bits to milliseconds, need to be converted to a timestamp of 10 bits to seconds (float type required)
table_modify_time=table_attr[' Modificationtime ']/1000.0
#使用localtime () and formatted output strftime () convert timestamps to normal format
Table_modify_time_format=time.strftime ('%y-%m-%d%h:%m:%s ', Time.localtime (table_modify_time))
Print (table_name)
Print (TABLE_ATTR)
Print (table_modify_time) #表的修改时间, sec
Print (Table_modify_time_format) #表的修改时间, formatted output
Print (")
The output is:
test_sh-fang20180604150605.sh
{u ' group ': U ' supergroup ', U ' permission ': U ' 644 ', U ' blockSize ': 134217728, U ' accesstime ': 1530720024452L, U ' pathsuffix ' : U ' test_sh-fang20180604150605.sh ', U ' modificationtime ': 1528095968096L, U ' replication ': 3, U ' length ': Ten, U ' Childrennum ': 0, U ' owner ': U ' appuser ', U ' storagepolicy ': 0, U ' type ': U ' FILE ', U ' fileId ': 26941}
1528095968.1
2018-06-04 15:06:08
Python operates HDFs and obtains the basic properties of the HDFs file name and file, including the modification time and conversion to standard Time