2014-05-17 2 views
-1

가장 가까운 "일치"를 찾으려면 한 디렉토리의 여러 파일을 다른 디렉토리의 여러 파일과 바이트 크기로 비교하고 싶습니다. 이것은 당신이 시작됩니다바이트로 여러 파일 비교하기

import os 
# these are lists of all the filenames in respective directories 
firstDir = os.listdir('first') 
secondDir = os.listdir('second') 
# I imagine using this for loop to compare the byte values, but I have no idea which method to use 
for item in firstDir 
    # ... 
+3

그래서 코드를 작성 하시겠습니까? 죄송합니다. 파이썬 문서로 이동하여 파일 관련 함수를 검색하고 숙제를하십시오. –

답변

1

, 나머지는 당신이 알아낼 수 있어야한다 :
이 지금까지 내 코드입니다.

import os 
p='yourdir' 
firstDir = os.listdir(p) 
for item in firstDir: 
    print os.path.getsize(p+"/"+item)