我有一个包含名称的文本文件。我希望用户输入任意3个名称并将其添加到一个空列表中。对于每个名称,我们都会告诉用户它们是否在附近。但是我收到了一个从setting_near
开始的错误。
user = input('Name any1 who is near to you ').split(',')
friends_open = open('friends.txt', 'r')
friends_read = friends_open.readlines()
friends_open.close()
near_by = []
near_by.append(user)
setting_near = set(near_by)
setting_friends = set(friends_read)
intersect = setting_near.intersection(setting_friends)
for n in intersect:
print(f'your {intersect} friend is here!! meet him ')
答案 0 :(得分:1)