从doc文件提取asn部分

1.把doc文件复制到记事本里
2.python代码
asn_statu = 0
asn_txt_list = []
with open("D:/share/doc/38413.txt",encoding="gbk") as file:
last_line = ""
for line in file:
if line.find('ASN1START') != -1:
asn_txt_list.append("--" +last_line)
asn_statu = 1

if asn_statu:
# print(line)
asn_txt_list.append(line)

if line.find('ASN1STOP') != -1:
asn_statu = 0
if line.strip() != " ":
last_line = line


with open("D:/share/doc/38413-f60.asn", "w") as file:
for x in asn_txt_list:
file.write(x)


posted @ 2020-07-07 12:35  耀耀王  阅读(280)  评论(0编辑  收藏  举报