Skip to content

Instantly share code, notes, and snippets.

@ox1111
Last active October 16, 2017 11:56
Show Gist options
  • Save ox1111/9406d5eba0c105b5a921d972219cfd3a to your computer and use it in GitHub Desktop.
Save ox1111/9406d5eba0c105b5a921d972219cfd3a to your computer and use it in GitHub Desktop.
파일 속성 가져오기
# -*- coding: utf-8 -*-
#
# write by kyoung chip , jang
#
# python 3.6
#
import hashlib
import sys
import os
import time
class CFileAttr :
def __init__( self ) :
pass
def doRead( self , file_name ) :
f = open( file_name , 'rb')
data = f.read()
f.close()
extension = os.path.splitext(file_name)[1][1:]
print('extension : ', extension )
print('MD5 : ', hashlib.md5(data).hexdigest() )
print('SHA-1 : ', hashlib.sha1(data).hexdigest() )
print('SHA-256 : ', hashlib.sha256(data).hexdigest() )
print('Access time : ', time.ctime(os.path.getatime( file_name )))
print('Modified time: ', time.ctime(os.path.getmtime( file_name )))
print('Change time : ', time.ctime(os.path.getctime( file_name )))
print('Size : ', os.path.getsize( file_name ) )
if __name__ == '__main__':
r = CFileAttr()
r.doRead("c:\\k\\python\\testlib2.cpp")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment