3
특정 유형의 파일을 폴더에서 감시하는 스크립트를 설정해야합니다. 필자는이 코드를 만들었지 만 더 좋은 방법이 있는지 궁금해하고 있었습니까?모범 사례 - 디렉토리를 보는 최선의 방법은 무엇입니까?
import os
def listAppleseedFiles(directory_path):
directory_entities = os.listdir(directory_path)
files = []
appleseed_files = []
for entity in directory_entities:
file_path = os.path.join(directory_path, entity)
if os.path.isfile(file_path):
if os.path.splitext(file_path)[1] == '.appleseed':
appleseed_files.append(file_path)
return appleseed_files
while True:
for file in listAppleseedFiles('/dir_name'):
doSomething()
가능한 중복 http://stackoverflow.com/questions/182197/how -do-i-watch-a-file-for-changes-python 사용) –