1. 文件操作
文件的操作方式有 打开文件, 读文件, 写文件, 关闭文件. 还会涉及一些系统路径, 路径下的文件夹和文件列表... 操作.
2. 辅助功能
对文件和文件夹的相关操作涉及到 os 模块 和 shutil 模块.
赋值方式 |
含义 |
os.listdir(“E:”) |
返回 E 盘目录下所有文件和目录 |
os.remove(“E:\a.txt”) |
删除 E 盘目录下的 a.txt 文件 |
os.removedirs(“E:\dir”) |
移除 E 盘目录 下的 dir 目录 Note: dir 目录下不能存在文件和文件夹 |
os.path.isfile(“E:\dir”) |
检查路径是否为文件, 是则返回 True, 否则返回 False |
os.path.isdir(“E:\dir”) |
检查路径是否为文件夹, 是则返回 True, 否则返回 False |
os.path.isabs(“E:\dir”) |
检查是否是绝对路径, 是则返回 True, 否则返回 False |
os.path.exists(“E:\dir”) |
检查路径是否存在, 是则返回 True, 否则返回 False |
os.path.split(“E:\dir\a.txt”) |
将路径切分开来, 例子返回 (‘E:\dir’, ‘a.txt’) |
os.path.splitext(“E:\dir\a.txt”) |
将文件名和文件类型分开来, 例子返回 (‘E:\dir\a’, ‘.txt’) Note: 如果路径为文件夹, 则类型为空 |
os.path.dirname(“E:\dir\a.txt”) |
获取当前路径的上级目录路径 |
os.path.basename(“E:\dir\a.txt”) |
获取当前路径的文件名或文件夹名 |
os.system(“dir”) |
运行 shell, 执行内建指令, 例子返回当前执行路径下的文件和文件夹 |
os.getenv(“JAVA_HOME”) |
获取环境变量, 传入变量名, 返回环境变量的路径 |
os.putenv(“TEST”, “E:\”) |
设置环境变量 |
os.name |
获取平台名 windows 返回 ‘nt’, Linux 返回 ‘posix’ |
os.mkdir(“E:\dir”) |
指定路径下创建文件夹 |
os.mkdirs(“E:\dir\subdir”) |
指定路径下创建多级文件夹 |
os.rmdir(“E:\dir”) |
只能删除空目录 |
os.chdir(“E:\dir”) |
切换路径到 E:\dir |
os.stat(“E:\a.txt”) |
获取文件的属性 |
os.chmod(“E:\a.txt”, stat.S_IXOTH) |
更改文件或目录的权限, 例子是修改 a.txt 的权限为其它用户有执行权限 |
os.path.getsize(“E:\a.txt”) |
获取文件大小, 单位为字节 |
shutil.copy(“oldfile”, “newfile”) |
oldfile 只能为文件夹, newfile 可以为文件或文件夹 |
shutil.copyfile(“oldfile”, “newfile”) |
oldfile 和 newfile 都只能为文件 |
shutil.copytree(“olddir”, “newdir”) |
oldfile 和 newfile 都只能为文件夹, 且 newfile 必须不存在 |
shutil.move(“oldpos”, “newpos”) |
移动文件或文件夹 |
shutil.rmtree(“dir”) |
不管目录是否为空, 都可以删除 |
3. 打开文件
打开文件方式共有如下几种
fp = open("E:\\a.txt", "r") // 只读方式打开 a.txt 文件
打开方式 |
含义 |
r |
读方式 |
w |
写方式 |
a |
追加方式, 不存在时会自动创建文件 |
r+ |
读写方式, 参见 r |
w+ |
读写方式, 参见 w |
a+ |
读写方式, 参见 a |
rb |
二进制读方式, 参见 r |
wb |
二进制写方式, 参见 w |
ab |
二进制追加方式, 参见 a |
rb+ |
二进制读写方式, 参见 r+ |
wb+ |
二进制读写方式, 参见 w+ |
ab+ |
二进制读写方式, 参见 a+ |
4. 读文件
读方式 |
含义 |
fp.read(size) |
size 为要读取的长度, 单位为字节 |
fp.readline()/fp.readline(size) |
读一行数据, 如果传入了 size, 可能返回一行的一部分 |
fp.readlines()/fp.readlines(size) |
文件的每行为 list 的一个成员, 返回 list, 内部也是调用 readline(), 如果传入 size, 则表示读取内容的总长, 则只会读到文件的一部分 |
5. 写文件
写方式 |
含义 |
fp.write(str) |
str 为要写入的数据, write() 不会自动在 str 后面添加换行符 |
fp.writelines(seq) |
把seq 内容写入文件中, 也不会在每行后面添加任何东西 |
6. 文件辅助
辅助方式 |
含义 |
fp.flush() |
把缓冲区的内容写入磁盘 |
fp.fileno() |
返回长整型的 “文件标签” |
fp.isatty() |
Linux 系统中用于 减产文件是否为终端设备文件 |
fp.tell() |
返回文件操作的当前位置, 已文件的开头为起点 |
fp.next() |
返回下一行, 并将文件操作标记移到下一行, 把一个 file 用于 for … in file 这样的语句时, 就是调用 next() 函数实现遍历的 |
fp.seek(off, whence) |
将文件偏移到 off 位置, off 为正, 则表示往后偏移, 为负, 则表示往前偏移 whence 代表从哪里开始计算偏移, 0: 表示从开头, 1: 表示从当前位置, 2: 表示从文件末尾 |
fp.truncate(size) |
把文件裁剪为 size 大小, 默认是裁到当前位置, 如果 size 比文件的大小还大, 则不改变文件, 也可能是用 0 把文件补到相应大小, 也可能是添加随机内容 |
7. 文件操作示例
示例为解析文件的内容, 并按指定的格式输出在终端显示
import os
fileDir = os.getcwd()
filePath = fileDir + "\\log.txt"
print(filePath)
file_Info_Size = (0x04 + 0x04 + 0x04 + 0xC80)*2
def analyze_mf(content):
print("**************************** MF Info Start ****************************")
off = 0
print("MF/DF/EF Common_Domain")
head_Array = [4, 2, 2, 2, 8]
head_Fid = content[off:(off+head_Array[0])]; off += head_Array[0]
head_Num = content[off:(off+head_Array[1])]; off += head_Array[1]
head_Class = content[off:(off+head_Array[2])]; off += head_Array[2]
head_Ac = content[off:(off+head_Array[3])]; off += head_Array[3]
head_OemId = content[off:(off+head_Array[4])]; off += head_Array[4]
print("\n head_Fid = %s\n head_Num = %s\n head_Class = %s\n head_Ac = %s\n head_OemId = %s\n" \
%(head_Fid, head_Num, head_Class, head_Ac, head_OemId) )
print("MF Private_Domain")
mf_Array = [128, 128, 32, 64, 64, 4, 4, 8, 8, 8, 8]
mf_Manufacturer = content[off:(off+mf_Array[ 0])]; off += mf_Array[ 0]
mf_Issuer = content[off:(off+mf_Array[ 1])]; off += mf_Array[ 1]
mf_Model = content[off:(off+mf_Array[ 2])]; off += mf_Array[ 2]
mf_Label = content[off:(off+mf_Array[ 3])]; off += mf_Array[ 3]
mf_SerialNumber = content[off:(off+mf_Array[ 4])]; off += mf_Array[ 4]
mf_HwVersion = content[off:(off+mf_Array[ 5])]; off += mf_Array[ 5]
mf_FirmwareVersion = content[off:(off+mf_Array[ 6])]; off += mf_Array[ 6]
mf_AlgSymCap = content[off:(off+mf_Array[ 7])]; off += mf_Array[ 7]
mf_AlgAsymCap = content[off:(off+mf_Array[ 8])]; off += mf_Array[ 8]
mf_AlgHashCap = content[off:(off+mf_Array[ 9])]; off += mf_Array[ 9]
mf_DevAuthAlgId = content[off:(off+mf_Array[10])]; off += mf_Array[10]
print("\n mf_Manufacturer = %s\n mf_Issuer = %s\n mf_Model = %s\n mf_Label = %s\n mf_SerialNumber = %s\n mf_HwVersion = %s\n mf_FirmwareVersion = %s\n mf_AlgSymCap = %s\n mf_AlgAsymCap = %s\n mf_AlgHashCap = %s\n mf_DevAuthAlgId = %s\n" \
%(mf_Manufacturer, mf_Issuer, mf_Model, mf_Label, mf_SerialNumber, mf_HwVersion, mf_FirmwareVersion, mf_AlgSymCap, mf_AlgAsymCap, mf_AlgHashCap, mf_DevAuthAlgId) )
print("MF Key_Domain---SM4")
mf_Sm4_Array = [32, 32, 32, 32]
mf_Sm4_Dev_Auth = content[off:(off+mf_Sm4_Array[0])]; off += mf_Sm4_Array[0]
mf_Sm4_App_Init = content[off:(off+mf_Sm4_Array[1])]; off += mf_Sm4_Array[1]
mf_Sm4_Boot = content[off:(off+mf_Sm4_Array[2])]; off += mf_Sm4_Array[2]
mf_Sm4_Transfer = content[off:(off+mf_Sm4_Array[3])]; off += mf_Sm4_Array[3]
print("\n mf_Sm4_Dev_Auth = %s\n mf_Sm4_App_Init = %s\n mf_Sm4_Boot = %s\n mf_Sm4_Transfer = %s\n" \
%(mf_Sm4_Dev_Auth, mf_Sm4_App_Init, mf_Sm4_Boot, mf_Sm4_Transfer) )
print("MF Key_Domain---RSA_1024")
mf_Rsa_1024_Array = [1416]
mf_Rsa_1024 = content[off:(off+mf_Rsa_1024_Array[0])]; off += mf_Rsa_1024_Array[0]
print("\n mf_Rsa_1024 = %s\n" %(mf_Rsa_1024))
print("MF Key_Domain---SM2")
mf_Sm2_Array = [192]
mf_Sm2 = content[off:(off+mf_Sm2_Array[0])]; off += mf_Sm2_Array[0]
print("\n mf_Sm2 = %s\n" %(mf_Sm2))
print("**************************** MF Info End ****************************")
def analyze_df(content):
print("**************************** DF Info Start ****************************")
off = 0
print("MF/DF/EF Common_Domain")
head_Array = [4, 2, 2, 2, 8]
head_Fid = content[off:(off+head_Array[0])]; off += head_Array[0]
head_Num = content[off:(off+head_Array[1])]; off += head_Array[1]
head_Class = content[off:(off+head_Array[2])]; off += head_Array[2]
head_Ac = content[off:(off+head_Array[3])]; off += head_Array[3]
head_OemId = content[off:(off+head_Array[4])]; off += head_Array[4]
print("\n head_Fid = %s\n head_Num = %s\n head_Class = %s\n head_Ac = %s\n head_OemId = %s\n" \
%(head_Fid, head_Num, head_Class, head_Ac, head_OemId) )
print("DF Private_Domain")
df_Array = [64, 64, 8, 2, 2, 64, 8, 2, 2, 2, 2, 2, 8]
df_ApplicationName = content[off:(off+df_Array[ 0])]; off += df_Array[ 0]
df_AdmainPin = content[off:(off+df_Array[ 1])]; off += df_Array[ 1]
df_AdmainPinRetryCount = content[off:(off+df_Array[ 2])]; off += df_Array[ 2]
df_MinAdmainPinLen = content[off:(off+df_Array[ 3])]; off += df_Array[ 3]
df_MaxAdmainPinLen = content[off:(off+df_Array[ 4])]; off += df_Array[ 4]
df_UserPin = content[off:(off+df_Array[ 5])]; off += df_Array[ 5]
df_UserPinRetryCount = content[off:(off+df_Array[ 6])]; off += df_Array[ 6]
df_MinUserPinLen = content[off:(off+df_Array[ 7])]; off += df_Array[ 7]
df_MaxUserPinLen = content[off:(off+df_Array[ 8])]; off += df_Array[ 8]
df_RsaNum = content[off:(off+df_Array[ 9])]; off += df_Array[ 9]
df_Sm2Num = content[off:(off+df_Array[10])]; off += df_Array[10]
df_SymNum = content[off:(off+df_Array[11])]; off += df_Array[11]
df_AlgFlags = content[off:(off+df_Array[12])]; off += df_Array[12]
print("\n df_ApplicationName = %s\n df_AdmainPin = %s\n df_AdmainPinRetryCount = %s\n df_MinAdmainPinLen = %s\n df_MaxAdmainPinLen = %s\n df_UserPin = %s\n df_UserPinRetryCount = %s\n df_MinUserPinLen = %s\n df_MaxUserPinLen = %s\n df_RsaNum = %s\n df_Sm2Num = %s\n df_SymNum = %s\n df_AlgFlags = %s\n" \
%(df_ApplicationName, df_AdmainPin, df_AdmainPinRetryCount, df_MinAdmainPinLen, df_MaxAdmainPinLen, df_UserPin, df_UserPinRetryCount, df_MinUserPinLen, df_MaxUserPinLen, df_RsaNum, df_Sm2Num, df_SymNum, df_AlgFlags) )
print("DF TokenFlag_Domain")
df_TokenFlag_Array = [8]
df_TokenFlag = content[off:(off+df_TokenFlag_Array[0])]; off += df_TokenFlag_Array[0]
print("\n df_TokenFlag = %s\n" %(df_TokenFlag))
print("DF PinCurrentRetryCount_Domain")
df_PinCurrentRetryCount_Array = [8, 8]
df_AdmainPinCurrentRetryCount = content[off:(off+df_PinCurrentRetryCount_Array[0])]; off += df_PinCurrentRetryCount_Array[0]
df_UserPinCurrentRetryCount = content[off:(off+df_PinCurrentRetryCount_Array[1])]; off += df_PinCurrentRetryCount_Array[1]
print("\n df_AdmainPinCurrentRetryCount = %s\n df_UserPinCurrentRetryCount = %s\n" \
%(df_AdmainPinCurrentRetryCount, df_UserPinCurrentRetryCount) )
print("DF Key_Domain---SM4")
df_Sm4_Array = [32, 32]
df_Sm4_Key_00 = content[off:(off+df_Sm4_Array[0])]; off += df_Sm4_Array[0]
df_Sm4_Key_01 = content[off:(off+df_Sm4_Array[1])]; off += df_Sm4_Array[1]
print("\n df_Sm4_Key_00 = %s\n df_Sm4_Key_01 = %s\n" \
%(df_Sm4_Key_00, df_Sm4_Key_01) )
print("DF Key_Domain---RSA_1024")
df_Rsa_1024_Array = [1416]
df_Rsa_1024 = content[off:(off+df_Rsa_1024_Array[0])]; off += df_Rsa_1024_Array[0]
print("\n df_Rsa_1024 = %s\n" %(df_Rsa_1024))
print("DF Key_Domain---SM2")
df_Sm2_Array = [192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192]
df_Sm2_00 = content[off:(off+df_Sm2_Array[ 0])]; off += df_Sm2_Array[ 0]
df_Sm2_01 = content[off:(off+df_Sm2_Array[ 1])]; off += df_Sm2_Array[ 1]
df_Sm2_02 = content[off:(off+df_Sm2_Array[ 2])]; off += df_Sm2_Array[ 2]
df_Sm2_03 = content[off:(off+df_Sm2_Array[ 3])]; off += df_Sm2_Array[ 3]
df_Sm2_04 = content[off:(off+df_Sm2_Array[ 4])]; off += df_Sm2_Array[ 4]
df_Sm2_05 = content[off:(off+df_Sm2_Array[ 5])]; off += df_Sm2_Array[ 5]
df_Sm2_06 = content[off:(off+df_Sm2_Array[ 6])]; off += df_Sm2_Array[ 6]
df_Sm2_07 = content[off:(off+df_Sm2_Array[ 7])]; off += df_Sm2_Array[ 7]
df_Sm2_08 = content[off:(off+df_Sm2_Array[ 8])]; off += df_Sm2_Array[ 8]
df_Sm2_09 = content[off:(off+df_Sm2_Array[ 9])]; off += df_Sm2_Array[ 9]
df_Sm2_0A = content[off:(off+df_Sm2_Array[10])]; off += df_Sm2_Array[10]
df_Sm2_0B = content[off:(off+df_Sm2_Array[11])]; off += df_Sm2_Array[11]
print("\n df_Sm2_00 = %s\n df_Sm2_01 = %s\n df_Sm2_02 = %s\n df_Sm2_03 = %s\n df_Sm2_04 = %s\n df_Sm2_05 = %s\n df_Sm2_06 = %s\n df_Sm2_07 = %s\n df_Sm2_08 = %s\n df_Sm2_09 = %s\n df_Sm2_0A = %s\n df_Sm2_0B = %s\n" \
%(df_Sm2_00, df_Sm2_01, df_Sm2_02, df_Sm2_03, df_Sm2_04, df_Sm2_05, df_Sm2_06, df_Sm2_07, df_Sm2_08, df_Sm2_09, df_Sm2_0A, df_Sm2_0B) )
print("DF Key_Domain---RSA_2048")
df_Rsa_2048_Array = [2826, 2826, 2826, 2826, 2826,2826, 2826, 2826, 2826, 2826, 2826, 2826, 2826]
df_Rsa_2048_00 = content[off:(off+df_Rsa_2048_Array[ 0])]; off += df_Rsa_2048_Array[ 0]
df_Rsa_2048_01 = content[off:(off+df_Rsa_2048_Array[ 1])]; off += df_Rsa_2048_Array[ 1]
df_Rsa_2048_02 = content[off:(off+df_Rsa_2048_Array[ 2])]; off += df_Rsa_2048_Array[ 2]
df_Rsa_2048_03 = content[off:(off+df_Rsa_2048_Array[ 3])]; off += df_Rsa_2048_Array[ 3]
df_Rsa_2048_04 = content[off:(off+df_Rsa_2048_Array[ 4])]; off += df_Rsa_2048_Array[ 4]
df_Rsa_2048_05 = content[off:(off+df_Rsa_2048_Array[ 5])]; off += df_Rsa_2048_Array[ 5]
df_Rsa_2048_06 = content[off:(off+df_Rsa_2048_Array[ 6])]; off += df_Rsa_2048_Array[ 6]
df_Rsa_2048_07 = content[off:(off+df_Rsa_2048_Array[ 7])]; off += df_Rsa_2048_Array[ 7]
df_Rsa_2048_08 = content[off:(off+df_Rsa_2048_Array[ 8])]; off += df_Rsa_2048_Array[ 8]
df_Rsa_2048_09 = content[off:(off+df_Rsa_2048_Array[ 9])]; off += df_Rsa_2048_Array[ 9]
df_Rsa_2048_0A = content[off:(off+df_Rsa_2048_Array[10])]; off += df_Rsa_2048_Array[10]
df_Rsa_2048_0B = content[off:(off+df_Rsa_2048_Array[11])]; off += df_Rsa_2048_Array[11]
df_Rsa_2048_0C = content[off:(off+df_Rsa_2048_Array[12])]; off += df_Rsa_2048_Array[12]
print("\n df_Rsa_2048_00 = %s\n df_Rsa_2048_01 = %s\n df_Rsa_2048_02 = %s\n df_Rsa_2048_03 = %s\n df_Rsa_2048_04 = %s\n df_Rsa_2048_05 = %s\n df_Rsa_2048_06 = %s\n df_Rsa_2048_07 = %s\n df_Rsa_2048_08 = %s\n df_Rsa_2048_09 = %s\n df_Rsa_2048_0A = %s\n df_Rsa_2048_0B = %s\n df_Rsa_2048_0C = %s\n" \
%(df_Rsa_2048_00, df_Rsa_2048_01, df_Rsa_2048_02, df_Rsa_2048_03, df_Rsa_2048_04, df_Rsa_2048_05, df_Rsa_2048_06, df_Rsa_2048_07, df_Rsa_2048_08, df_Rsa_2048_09, df_Rsa_2048_0A, df_Rsa_2048_0B, df_Rsa_2048_0C) )
print("**************************** DF Info End ****************************")
def analyze_ef(content, father_Aid):
print("**************************** EF Info Start ****************************")
off = 0
print("Current_EF belongs to Father_DF: " + father_Aid)
print("MF/DF/EF Common_Domain")
head_Array = [4, 2, 2, 2, 8]
head_Fid = content[off:(off+head_Array[0])]; off += head_Array[0]
head_Num = content[off:(off+head_Array[1])]; off += head_Array[1]
head_Class = content[off:(off+head_Array[2])]; off += head_Array[2]
head_Ac = content[off:(off+head_Array[3])]; off += head_Array[3]
head_OemId = content[off:(off+head_Array[4])]; off += head_Array[4]
print("\n head_Fid = %s\n head_Num = %s\n head_Class = %s\n head_Ac = %s\n head_OemId = %s\n" \
%(head_Fid, head_Num, head_Class, head_Ac, head_OemId) )
print("EF Private_Domain")
ef_Array = [64]
ef_FileName = content[off:(off+ef_Array[0])]; off += ef_Array[0]
print("\n ef_FileName = %s\n" %(ef_FileName))
print("EF Content")
ef_Content = content[off:]
print("\n ef_Content = %s\n" %(ef_Content))
print("**************************** EF Info End ****************************")
def display_file_Info():
print("**************************** Display_File_Num Start ****************************")
fp = open(filePath, 'r')
content = fp.read(file_Info_Size)
file_num = 0
file_size = []
file_off = []
off = 0
print("FileSystem Base Info")
fileSystem_Array = [8, 8, 8]
current_State = content[off:(off+fileSystem_Array[0])]; off += fileSystem_Array[0]
used_Memory = content[off:(off+fileSystem_Array[1])]; off += fileSystem_Array[1]
remain_Memory = content[off:(off+fileSystem_Array[2])]; off += fileSystem_Array[2]
print("\n current_State = %s\n used_Memory = %s\n remain_Memory = %s\n" \
%(current_State, used_Memory, remain_Memory) )
print("FileSystem Offset Info")
print ("Fid Type Exist Level Total_Size Used_Size Addr_Offset Father_Fid Father_Aid Aid")
for i in range(38):
offset_Array = [4, 2, 2, 2, 8, 8, 8, 4, 64, 64]
fid = content[off:(off+offset_Array[0])]; off += offset_Array[0]
type = content[off:(off+offset_Array[1])]; off += offset_Array[1]
exist = content[off:(off+offset_Array[2])]; off += offset_Array[2]
level = content[off:(off+offset_Array[3])]; off += offset_Array[3]
total_size = content[off:(off+offset_Array[4])]; off += offset_Array[4]
used_size = content[off:(off+offset_Array[5])]; off += offset_Array[5]
addr_offset = content[off:(off+offset_Array[6])]; off += offset_Array[6]
father_fid = content[off:(off+offset_Array[7])]; off += offset_Array[7]
father_aid = content[off:(off+offset_Array[8])]; off += offset_Array[8]
aid = content[off:(off+offset_Array[9])]; off += offset_Array[9]
if ( (exist == "01") and (fid != "FFFF") ):
print("%s %s %s %s %s %s %s %s %s %s" %(fid, type, exist, level, total_size, used_size, addr_offset, father_fid, father_aid, aid))
file_num += 1
file_size.append(int(total_size, 16))
file_off.append(int(addr_offset, 16))
print("FileSystem Detail Info")
print("file_num = %d\n" %file_num)
for i in range(file_num):
print("file_size[%.2d] = 0x%.8x, file_off[%.2d] = 0x%.8x" %(i, file_size[i], i, file_off[i]))
fp.close()
print("**************************** Display_File_Num End ****************************")
def main():
display_file_Info()
print ("\n\n\n****************************** Start Analyze ******************************\n")
with open(filePath, 'r') as fp:
fp.read(24)
for i in range(38):
off = 0
content = fp.read(166)
offset_Array = [4, 2, 2, 2, 8, 8, 8, 4, 64, 64]
fid = content[off:(off+offset_Array[0])]; off += offset_Array[0]
type = content[off:(off+offset_Array[1])]; off += offset_Array[1]
exist = content[off:(off+offset_Array[2])]; off += offset_Array[2]
level = content[off:(off+offset_Array[3])]; off += offset_Array[3]
total_size = content[off:(off+offset_Array[4])]; off += offset_Array[4]
used_size = content[off:(off+offset_Array[5])]; off += offset_Array[5]
addr_offset = content[off:(off+offset_Array[6])]; off += offset_Array[6]
father_fid = content[off:(off+offset_Array[7])]; off += offset_Array[7]
father_aid = content[off:(off+offset_Array[8])]; off += offset_Array[8]
aid = content[off:(off+offset_Array[9])]; off += offset_Array[9]
if ( (exist == "01") and (fid != "FFFF") ):
fp.seek(file_Info_Size+int(addr_offset, 16)*2,0)
file_content = fp.read(int(total_size, 16)*2)
if type == "00":
analyze_mf(file_content)
elif type == "01":
analyze_df(file_content)
elif type == "02":
analyze_ef(file_content, father_aid)
else:
raise "File Type Error"
fp.seek(24 + (i+1)*166, 0)
print ("\n\n\n****************************** End Analyze ******************************\n")
if __name__ == "__main__":
main()