【发布时间】:2015-07-05 09:08:17
【问题描述】:
我想查找两个文件中的所有唯一词。我能够列出每个文件中的所有单词,但它给了我重复项。我也想按字母顺序对它们进行排序。我该怎么做?
#!/usr/bin/python3
#First file
file = raw_input("Please enter the name of the first file: ")
store = open(file)
new = store.read()
#Second file
file2 = raw_input("Please enter the name of the second file: ")
store2 = open(file2)
new2 = store2.read()
for line in new.split():
if line in new2:
print line
【问题讨论】:
标签: python list input store words