一个python写的去c语言注释的小脚本
2018-07-20 来源:open-open
#!/usr/bin/python import sys input = sys.argv[1] fp = open(input,"r") flag = 0 quote = 0 for line in fp: myline = "" length = len(line) for index in range(length): if flag == 0 and quote == 0 and line[index] == "\"": quote = 1 myline += line[index] continue if flag == 0 and quote == 1 and line[index] == "\"": quote = 0 myline += line[index] continue if quote != 1 and flag == 2 and line[index] == "\n": flag = 0 if quote != 1 and flag == 0 and line[index] == "/" and line[index+1] == "*": flag = 1 if quote != 1 and index > 0 and flag == 1 and line[index-1] == "/" and line[index-2] == "*": flag = 0 if quote != 1 and flag == 0 and line[index] == "/" and line[index+1] == "/": flag = 2 if flag == 1 or flag == 2: continue myline += line[index] print myline, fp.close()
标签:
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点!
本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。
上一篇:C#实现MD5加密
下一篇:Java序列化和反序列化例子
最新资讯
热门推荐