import os, sys
def crawlLocalDirectories(directoryToCrawl):
crawledDirectory = [os.path.join(path, subname) for path, dirnames, filenames in os.walk(directoryToCrawl) for subname in dirnames + filenames]
return crawledDirectory
print crawlLocalDirectories('.')
dictionarySize = {}
def getSizeOfFiles(filesToMeasure):
for everyFile in filesToMeasure:
size = os.path.getsize(everyFile)
dictionarySize[everyFile] = size
return dictionarySize
print getSizeOfFiles(crawlLocalDirectories('.'))
每当运行此程序时,我都会得到 的输出{'example.py':392L}
,为什么?什么是L?我不想在最后把 L 去掉。
如果我在不将其添加到字典的情况下运行它,它会返回文件大小为392
.