fPath = raw_input('File Path:')
counter = 0;
flag = 0;
with open(fPath) as f:
content = f.readlines()
for line in content:
if flag == 0 and line.find("WECS number") or \
line.find("WECS number") or \
line.find("WECS name") or \
line.find("Manufacturer") or \
line.find("Type") or \
line.find("Nominal effect") or \
line.find("Hub height") or \
line.find("x (local)") or \
line.find("y (local)") or \
line.find("x (global)") or \
line.find("y (global)"):
if not line.find("y (global)"):
print ("Alert Last Line!");
else:
print("Alert Line!");
出于某种原因,代码似乎正在打印“警报行!” 如果一行只是“\n”。我创建“if and or”结构的意图是忽略所有不包含line.find
's 中列出的字符串的行。这里出了点问题……
我该如何解决这个问题?