标签:代码 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)
标签:代码 har gbk with open 复制 list end sha lin
原文地址:https://www.cnblogs.com/Ziee/p/13260100.html