码迷,mamicode.com
首页 > 其他好文 > 详细

从doc文件提取asn部分

时间:2020-07-07 13:07:23      阅读:79      评论:0      收藏:0      [点我收藏+]

标签:代码   har   gbk   with open   复制   list   end   sha   lin   

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)


从doc文件提取asn部分

标签:代码   har   gbk   with open   复制   list   end   sha   lin   

原文地址:https://www.cnblogs.com/Ziee/p/13260100.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!