Python Valueerror : Too Many Values To Unpack, Solution?
Im getting this error and i have no idea what it means, i can get the program to print the files from there values but its just a long incoherent now im trying to get it to print
Solution 1:
Your files_only_x
is a set of single values; your listfiles()
function returns a list of strings, not of tuples with 3 values:
for fname in files_only_x:
print ('\\%s' % fname)
Solution 2:
You built files
as a list of strings, therefore the loop in your 2nd code block is wrong as it suggests files
is list of 3-value tuples.
Solution 3:
Look at the data flow:
You call listfiles()
with a path. It collects all files below that path in a list.
(BTW, IMHO dir = dirName.replace(path, '')
is dangerous. What happens if path
is lib/
and you encouter a sub path lib/misc/collected/lib/whatever
? While this path males not much sense, it might have been created...)
You return this list from listfiles()
and then convert them into sets.
If you try to iterate over these sets, you get one path per iteration step.
Post a Comment for "Python Valueerror : Too Many Values To Unpack, Solution?"