• <small id='FK4Ef'></small><noframes id='FK4Ef'>

      <bdo id='FK4Ef'></bdo><ul id='FK4Ef'></ul>
  • <legend id='FK4Ef'><style id='FK4Ef'><dir id='FK4Ef'><q id='FK4Ef'></q></dir></style></legend>
      <i id='FK4Ef'><tr id='FK4Ef'><dt id='FK4Ef'><q id='FK4Ef'><span id='FK4Ef'><b id='FK4Ef'><form id='FK4Ef'><ins id='FK4Ef'></ins><ul id='FK4Ef'></ul><sub id='FK4Ef'></sub></form><legend id='FK4Ef'></legend><bdo id='FK4Ef'><pre id='FK4Ef'><center id='FK4Ef'></center></pre></bdo></b><th id='FK4Ef'></th></span></q></dt></tr></i><div id='FK4Ef'><tfoot id='FK4Ef'></tfoot><dl id='FK4Ef'><fieldset id='FK4Ef'></fieldset></dl></div>

      <tfoot id='FK4Ef'></tfoot>
      1. 两个文本文件之间的差异和交叉报告

        Diff and intersection reporting between two text files(两个文本文件之间的差异和交叉报告)

        <small id='mbw42'></small><noframes id='mbw42'>

        <legend id='mbw42'><style id='mbw42'><dir id='mbw42'><q id='mbw42'></q></dir></style></legend>

        • <i id='mbw42'><tr id='mbw42'><dt id='mbw42'><q id='mbw42'><span id='mbw42'><b id='mbw42'><form id='mbw42'><ins id='mbw42'></ins><ul id='mbw42'></ul><sub id='mbw42'></sub></form><legend id='mbw42'></legend><bdo id='mbw42'><pre id='mbw42'><center id='mbw42'></center></pre></bdo></b><th id='mbw42'></th></span></q></dt></tr></i><div id='mbw42'><tfoot id='mbw42'></tfoot><dl id='mbw42'><fieldset id='mbw42'></fieldset></dl></div>

          1. <tfoot id='mbw42'></tfoot>

                <bdo id='mbw42'></bdo><ul id='mbw42'></ul>

                    <tbody id='mbw42'></tbody>
                  本文介绍了两个文本文件之间的差异和交叉报告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  免责声明:我是一般编程和脚本的新手,所以请原谅缺乏技术术语

                  所以我有两个包含列出名称的文本文件数据集:

                  So i have two text file data sets that contain names listed:

                  First File | Second File
                  bob        | bob
                  mark       | mark
                  larry      | bruce
                  tom        | tom
                  

                  我想运行一个脚本(pref python),在一个文本文件中输出相交线,在另一个文本文件中输出不同的线,例如:

                  I would like to run a script (pref python) that outputs the intersection lines in one text file and the different lines in another text file, ex:

                  matches.txt:

                  bob 
                  mark 
                  tom 
                  

                  differences.txt:

                  bruce
                  

                  我将如何使用 Python 完成此任务?或者使用 Unix 命令行,如果它足够简单的话?

                  How would I accomplish this with Python? Or with a Unix command line, if it's easy enough?

                  推荐答案

                  words1 = set(open("some1.txt").read().split())
                  words2 = set(open("some2.txt").read().split())
                  
                  duplicates  = words1.intersection(words2)
                  uniques = words1.difference(words2).union(words2.difference(words1))
                  
                  print "Duplicates(%d):%s"%(len(duplicates),duplicates)
                  print "
                  Uniques(%d):%s"%(len(uniques),uniques)
                  

                  至少是这样的

                  这篇关于两个文本文件之间的差异和交叉报告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  groupby multiple coords along a single dimension in xarray(在xarray中按单个维度的多个坐标分组)
                  Group by and Sum in Pandas without losing columns(Pandas中的GROUP BY AND SUM不丢失列)
                  Group by + New Column + Grab value former row based on conditionals(GROUP BY+新列+基于条件的前一行抓取值)
                  Groupby and interpolate in Pandas(PANDA中的Groupby算法和插值算法)
                  Pandas - Group Rows based on a column and replace NaN with non-null values(PANAS-基于列对行进行分组,并将NaN替换为非空值)
                  Grouping pandas DataFrame by 10 minute intervals(按10分钟间隔对 pandas 数据帧进行分组)

                    <legend id='sP8cA'><style id='sP8cA'><dir id='sP8cA'><q id='sP8cA'></q></dir></style></legend>
                    <i id='sP8cA'><tr id='sP8cA'><dt id='sP8cA'><q id='sP8cA'><span id='sP8cA'><b id='sP8cA'><form id='sP8cA'><ins id='sP8cA'></ins><ul id='sP8cA'></ul><sub id='sP8cA'></sub></form><legend id='sP8cA'></legend><bdo id='sP8cA'><pre id='sP8cA'><center id='sP8cA'></center></pre></bdo></b><th id='sP8cA'></th></span></q></dt></tr></i><div id='sP8cA'><tfoot id='sP8cA'></tfoot><dl id='sP8cA'><fieldset id='sP8cA'></fieldset></dl></div>

                      <tbody id='sP8cA'></tbody>

                    <tfoot id='sP8cA'></tfoot>
                  • <small id='sP8cA'></small><noframes id='sP8cA'>

                      • <bdo id='sP8cA'></bdo><ul id='sP8cA'></ul>