001KTqJHzy6XX4k5wFk5a

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#?-*-?coding:?UTF-8?-*-
file?=?input("請輸入文件路徑:")
word1?=?input("請輸入要替換的詞:")
word2?=?input("請輸入新的詞:")
f=open(file,"r+")
AAA=f.read()
count?=?0
def?BBB():
????global?count
????for?each?in?AAA:
????????if?each?==?word1:
????????????count=count+1
????print("一共有【"+str(count)+"】處要找的【"+str(word1)+"】")
BBB()
#紅色這一段其實是最最容易蒙圈的地方#
print("您確定要把所有的【"+str(word1)+"】替換為【"+str(word2)+"】嗎?")
K=input("【YES/NO】:")
AAA=AAA.replace(word1,word2)
while?True:
????if?K=="YES"?or?K=="yes":
????????print(AAA)
????????break
????else:
????????print("操作取消!")
????????break