从一个位于/* */
和{
For line in file:
if def0Encountered == 0:
if Line.strip().startswith('#if 0') == True:
Def0StartsAt = Line.find('#if 0')
def0Encountered = 1
if Line.find('#endif')!= -1:
def0Encountered = 0
Def0EndsAt = Line.find('endif')
Line = Line[0:Def0StartsAt] + Line[Def0EndsAt + 2 : ]
List = Line.split()
您可以使用正则表达式将文件中不需要的部分替换为空字符串(注意,这是非常基本的,它不适用于嵌套宏):
不确定这个奇怪的代码应该做什么,但是可以直接逐行遍历文件。使用两个标志检查是否在注释或和if块内。根据字符串比较切换标志。根据这两个标志的值,您要么输出当前行,要么忽略它。。。。在
相关问题 更多 >
编程相关推荐