-1
기본적으로 다음과 같은 목록을 생성하는 지정된 범위의 함수를 만듭니다 (예 : 7).일반적인 접두사와 고유 한 정수가있는 파일 이름 목록을 최종 문자로 생성하는 함수를 만듭니다.
여기list_of_filenames = ['my_file1.json', 'my_file2.json', 'my_file3.json', 'my_file4.json', 'my_file5.json,' 'my_file6.json', 'my_file7.json']
는 지금까지이 작업은 다음과 같습니다
def make_files_list(file_prefix):
filenames_list = []
for file in range(7):
file = '{0}'.format(file_prefix)+ str(1) + '.json'
filenames_list.append(file)
return filenames_list
final_files_list = make_files_list('my_file')
그러나 물론, 난 그냥 모든 동일한 파일 이름의 목록을 '1'과 같은 마지막 문자로 :
list_of_filenames = ['my_file1.json', 'my_file1.json', 'my_file1.json', 'my_file1.json', 'my_file1.json,' 'my_file1.json', 'my_file1.json']
필자의 기능이 제대로 작동하지 않는 이유를 알고 있지만 후속 정수를 각 후속 목록 항목에 추가하도록 수정하는 방법을 모르겠습니다.
그것은'STR (파일)'하지해야이 하나를 시도'STR (1)'. – zondo
도움 주셔서 대단히 감사합니다! – TJE