使用python移出重复的行

使用python移出重复的行

#!/usr/bin/env python

f = open("c:\\temp\\Original.txt")
f2 = open("c:\\temp\\Unique.txt", "w")
uniquelines = set(f.read().split("\n"))
f2.write("".join([line + "\n" for line in uniquelines]))
f2.close()

Comments

  1. 呵呵,咋不用 '\n'.join……或者 f2.writelines……

    ReplyDelete

Post a Comment

Popular posts from this blog

周末发现的两样东西,和心理有关的。

QStringList related performance