我正在尝试在文件中找到关键字,如果找到则通过该行进行进一步处理。我以前实现过类似的方法。但奇怪的是,这不起作用。我无法找到我犯错的地方。有一些指导会很棒。
我的代码:
def Find_Prepend_Data(Opened_File, Opened_Cpp_File):
Prepend_Data_Keyword = '#include '
# Find_In_Source_File_And_Write(Opened_File, Opened_Cpp_File, Prepend_Data_Keyword)
for line in Opened_Cpp_File:
Keyword_Matched = [True for match in Prepend_Data_Keyword if match in line]
if True in Keyword_Matched:
Found_Prepend_Data = Prepend_Data(Opened_File, line)
print str(Found_Prepend_Data)
return
def Prepend_Data(Opened_File, Prepend_Data):
Prepend_Data_Value = "\n" + Prepend_Data
Write_Data(Opened_File, Prepend_Data_Value)
return Prepend_Data_Value
我以前的类似帖子: