答案解析
file_list = ['foo.py', 'bar.txt', 'spam.py', 'animal.png', 'test.pyc']
py_list = []
for file in file_list:
if file.endswith('.py'):
py_list.append(file)
print(py_list)