一句正则表达式删除所有C语言注释,正则表达式注释,import recod
一句正则表达式删除所有C语言注释,正则表达式注释,import recod
import recode_file = open('test.c','r')code_content = code_file.read()code_content_temp = re.sub(r'((?<=\n)|^)[ \t]*\/\*.*?\*\/\n?|\/\*.*?\*\/|((?<=\n)|^)[ \t]*\/\/[^\n]*\n|\/\/[^\n]*','',code_content)print(code_content_temp)
评论关闭