29讲最后一题,大神帮看看哪里有问题
file = input('请输入文件名:')old_str = input('请输入需要替换的字符')
nwe_str = input('请输入新的字符')
f = open('E:\\python\\liu\\'+file,encoding='utf-8')
f.read()
for eachline in f:
for i in eachline:
if i == old_str:
eachline = eachline.replace(old_str,nwe_str)
print(*eachline,sep ='\n')
f.close()
{:10_254:} {:10_254:} {:10_254:} f.read()已经到文件尾了,在for循环没有内容了。
页:
[1]