-2
我想写一个文件,审查单词“冬天”,但由于某种原因,我的代码不工作,虽然我没有错误。帮帮我!问题与审查蟒蛇脚本
filename = input("Enter file name (without extension): ")
file1 = filename+".txt"
file2 = filename+"_censored.txt"
word = input("Enter the word you are searching for: ")
#In this case, the input would be "winter"
print("\nLooping through the file, line by line.")
in_text_file = open(file1, "r")
out_text_file = open(file2,"w")
for line in in_text_file:
print(line)
out_text_file.write(line)
n = [ ]
def censor(word, filename):
for i in text.split(''):
if i == word:
i = "*" * len(word)
n.append(i)
else:
n.append(i)
return ' '.join(n)
in_text_file.close()
out_text_file.close()
开始通过固定的压痕 – njzk2
你的缩进是靠不住的。你能解决它吗? – James