이 함수를 해결하기 위해 다른 함수를 호출하려고했지만이 함수는 다른 함수에서 정의 되었더라도이 파일이 정의되어 있지 않다는 오류 메시지가 표시됩니다.사전에서 날짜별로 목록으로 이미지 정렬
filename_dict = create_image_dict(open_csv_file)
builtins.NameError: name 'open_csv_file' is not defined
이 작업을 수행하는 다른 방법이 있는지 궁금합니다. 누구든지 나를 도울 수 있습니까?
def sorted_images(image_dict):
'''(dict) -> list of str
Given an image dictionary return a list of the filenames
sorted by date.
>>> d = {'image1.jpg': ['UTSC', '2017-11-03','Happy Friday'], \
'image2.jpg': ['UTSC', '2017-11-04', 'Happy Sat.']}
>>> sorted_images(d)
['image1.jpg', 'image2.jpg']
'''
new_list = []
filename_dict = create_image_dict(open_csv_file)
sub_dict = filename_dict[filename]
early_date = 0
early_filename = ''
for (location, date, caption) in sub_dict.items():
if date > early_date:
early_filename = filename
new_list.append(early_filename)
return new_list
"open_csv_file"은 어디에 정의합니까? 전체 코드를 게시 할 수 있습니까? –
다른 함수에서 정의했습니다. 다른 함수를 호출하려고합니다. – bigd
그래서 ..... wheer는 다른 함수입니까? 스코프를 볼 필요가 있습니다. 범위를 벗어났습니다. 내 PC에서 변수를 선언하면 볼 수 없습니다. –