import time
def get_file_encoding(src_file_path):
"""
Get the encoding type of a file
:param src_file_path: file path
:return: str - file encoding type
"""
with open(src_file_path) as src_file:
return src_file.encoding
file_path = input('Please enter file path: ')
start_time = time.perf_counter()
print(get_file_encoding(file_path))
print('get file encoding: {}'.format(time.perf_counter() - start_time))
Comments