Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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 it in an organized manor and thats where the issues arise.

import os 
def listfiles (path):
    files = []
    for dirName, subdirList, fileList in os.walk(path):
        dir = dirName.replace(path, '')
        for fname in fileList:
            files.append(os.path.join(dir, fname))
    return files

a = input('Enter a primary file path: ')
b = input('Enter a secondary file path: ')

x = listfiles(a)
y = llistfiles(b)

files_only_x = set(x) - set (y)
files_only_y = set(y) - set (x)

this next line of code is where python is saying the error is

for dirName, subdirList, fileList in files_only_x:
    print ('Directory: %s' % dirName)
    for fname in fileList:
        print ('\%s' % fname)
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
210 views
Welcome To Ask or Share your Answers For Others

1 Answer

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)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...