V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
karlxu
V2EX  ›  问与答

Python 里两个文件对比速度问题

  •  
  •   karlxu · Jun 6, 2018 · 1478 views
    This topic created in 2889 days ago, the information mentioned may be changed or developed.
    两个文件都是 1 万行,每一行的数据都不一样,
    d = difflib.HtmlDiff()
    d.make_file(file1,file2)
    使用 difflib 对比生成 html,发现速度奇慢。。。大概 30 分钟
    请教下有没有其他方法?谢谢
    3 replies    2018-06-06 17:31:10 +08:00
    wplct
        1
    wplct  
       Jun 6, 2018
    ??? 要不 用 set ?
    karlxu
        2
    karlxu  
    OP
       Jun 6, 2018
    @wplct set 集合去重?我不需要去重。。。只是两个文件对比。
    wplct
        3
    wplct  
       Jun 6, 2018
    set 的 交集 并集操作了解一下
    set1 & set2
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   747 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 32ms · UTC 20:36 · PVG 04:36 · LAX 13:36 · JFK 16:36
    ♥ Do have faith in what you're doing.