0
import os
def search_dir(dir,topdown=True):
files = {}
for root, dirs, files in os.walk(dir, topdown):
for name in files:
fileAdd = os.path.join(root,name)
fileSize = os.path.getsize(fileAdd)
files[fileAdd] = str(fileSize);
print (fileAdd + ', Size:' + str(fileSize)+'kb')
for name in dirs:
fileAdd = os.path.join(root,name)
fileSize = os.path.getsize(fileAdd)
files[fileAdd] = fileSize;
print (fileAdd + ', Size:'+ str(fileSize)+'kb')
dir = raw_input('please input the path:')
search_dir(dir)
for fileAdd in sorted(files):
print("{0} size {1}kb".format(fileAdd, files[fileAdd]))
終端說「列表索引必須是整數不是str」,我不知道爲什麼?列表索引必須是整數不是str
是的,你說得對,非常感謝你。 – tonysok
StackOverflow *是一種分佈式調試器。我敢打賭,它通常比使用真正的調試器更快...;) – Bitwise
@Bitwise - 嗯,我有點像這樣的想法。 – tdelaney