我想找到所有的独特的话,在这两个文件。我能列出每个文件中的所有单词,但它给了我副本。我还想按字母顺序排列。我该怎么做呢?你知道吗
#!/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
以下是一个可能对您有所帮助的片段:
更新:
如果您只对两个文件共用的单词感兴趣,请执行以下操作:
相关问题 更多 >
编程相关推荐