最近看到了一段代码,以下简单节录
targetDir = 'OOOO'
keyword = 'https:/.......='
with open(fpath, encoding='utf8') as f:
lines = f.readlines()
# 新文件的内容
newContent = ''
isChanged = False
# 一行行分析
for line in lines:
pos1 = line.find(keyword)
if pos1 < 0:
newContent += line
else:
isChanged = True
# 计算上标下标
startPos = pos1 + len(keyword)
endPos = startPos
while True:
endPos += 1
if not line[startPos:endPos].isdigit():
break
num = int(line[startPos:endPos-1]) + 3
newContent += line[:startPos] + str(num) + line[endPos-1:]
# 判断改变
if isChanged:
print(f"{fpath} 改变")
想问一下,python isChanged 是函数 还是keywords?
isChanged 到底是什么? google之后都没有结果?
谢谢!