问题描述:
def showfileproperties(path):
import os,time
for root,files in os.walk(path,True):
print(‘位置: ’ + root)
遍历时出现以下错误:
File “C:/Users/123/PycharmProjects/untitled1/a5.py”, line 3, in showfileproperties
for root,files in os.walk(path,True):
ValueError: too many values to unpack (expected 2)
调整后:
def showfileproperties(path):
import os,time
for root,dirs,files in os.walk(path,True):
print(‘位置: ’ + root)
原因:
字典遍历时访问key,