纯小bai为什么上部分会报错 下面不会 看半天没看出那里有问题啊 有没有人解答一下
filenames = ['cats.txt','dogs.txt']
for filename in filenames:
print(f"\nReading file:{filename}")
try:
with open(filename) as c:
file = c.read()
print(file)
except FileExistsError:
print(" Sorry, I can't find that file.")
filenames = ['cats.txt', 'dogs.txt']
for filename in filenames:
print(f"\nReading file: {filename}")
try:
with open(filename) as c:
contents = c.read()
print(contents)
except FileNotFoundError:
print(" Sorry, I can't find that file.")