파이썬을 사용하여 최신 폴더 파일을 가져와야합니다. 코드를 사용하는 동안 :
max(files, key = os.path.getctime)
아래 오류가 발생합니다.
FileNotFoundError: [WinError 2] The system cannot find the file specified: 'a'
files
변수에 할당 된 것이 잘못되었습니다. 다음 코드를 사용하십시오.
import glob
import os
list_of_files = glob.glob('/path/to/folder/*') # * means all if need specific format then *.csv
latest_file = max(list_of_files, key=os.path.getctime)
print(latest_file)
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다