最近看到了一段代碼,以下簡單節錄
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之後都沒有結果?
謝謝!