久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

<legend id='kpTaT'><style id='kpTaT'><dir id='kpTaT'><q id='kpTaT'></q></dir></style></legend>
    1. <tfoot id='kpTaT'></tfoot>

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

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

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

        在 Python 中合并和排序日志文件

        Merging and sorting log files in Python(在 Python 中合并和排序日志文件)

        <small id='2KpQ1'></small><noframes id='2KpQ1'>

        <i id='2KpQ1'><tr id='2KpQ1'><dt id='2KpQ1'><q id='2KpQ1'><span id='2KpQ1'><b id='2KpQ1'><form id='2KpQ1'><ins id='2KpQ1'></ins><ul id='2KpQ1'></ul><sub id='2KpQ1'></sub></form><legend id='2KpQ1'></legend><bdo id='2KpQ1'><pre id='2KpQ1'><center id='2KpQ1'></center></pre></bdo></b><th id='2KpQ1'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='2KpQ1'><tfoot id='2KpQ1'></tfoot><dl id='2KpQ1'><fieldset id='2KpQ1'></fieldset></dl></div>
          1. <tfoot id='2KpQ1'></tfoot>
              <bdo id='2KpQ1'></bdo><ul id='2KpQ1'></ul>
                <tbody id='2KpQ1'></tbody>

                  <legend id='2KpQ1'><style id='2KpQ1'><dir id='2KpQ1'><q id='2KpQ1'></q></dir></style></legend>

                1. 本文介紹了在 Python 中合并和排序日志文件的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我對 python 完全陌生,但我遇到了一個無法解決的嚴重問題.

                  I am completely new to python and I have a serious problem which I cannot solve.

                  我有幾個結構相同的日志文件:

                  I have a few log files with identical structure:

                  [timestamp] [level] [source] message
                  

                  例如:

                  [Wed Oct 11 14:32:52 2000] [error] [client 127.0.0.1] error message
                  

                  我需要用純 Python 編寫一個程序,它將這些日志文件合并到一個文件中,然后按時間戳對合并后的文件進行排序.在此操作之后,我希望將此結果(合并文件的內容)打印到 STDOUT(控制臺).

                  I need to write a program in pure Python which should merge these log files into one file and then sort the merged file by timestamp. After this operation I wish to print this result (the contents of the merged file) to STDOUT (console).

                  我不明白該怎么做,希望得到幫助.這可能嗎?

                  I don't understand how to do this would like help. Is this possible?

                  推薦答案

                  你可以這樣做

                  import fileinput
                  import re
                  from time import strptime
                  
                  f_names = ['1.log', '2.log'] # names of log files
                  lines = list(fileinput.input(f_names))
                  t_fmt = '%a %b %d %H:%M:%S %Y' # format of time stamps
                  t_pat = re.compile(r'[(.+?)]') # pattern to extract timestamp
                  for l in sorted(lines, key=lambda l: strptime(t_pat.search(l).group(1), t_fmt)):
                      print l,
                  

                  這篇關于在 Python 中合并和排序日志文件的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  python: Two modules and classes with the same name under different packages(python:不同包下同名的兩個模塊和類)
                  Configuring Python to use additional locations for site-packages(配置 Python 以使用站點包的其他位置)
                  How to structure python packages without repeating top level name for import(如何在不重復導入頂級名稱的情況下構造python包)
                  Install python packages on OpenShift(在 OpenShift 上安裝 python 包)
                  How to refresh sys.path?(如何刷新 sys.path?)
                  Distribute a Python package with a compiled dynamic shared library(分發帶有已編譯動態共享庫的 Python 包)
                    <bdo id='ReEKY'></bdo><ul id='ReEKY'></ul>
                        <i id='ReEKY'><tr id='ReEKY'><dt id='ReEKY'><q id='ReEKY'><span id='ReEKY'><b id='ReEKY'><form id='ReEKY'><ins id='ReEKY'></ins><ul id='ReEKY'></ul><sub id='ReEKY'></sub></form><legend id='ReEKY'></legend><bdo id='ReEKY'><pre id='ReEKY'><center id='ReEKY'></center></pre></bdo></b><th id='ReEKY'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='ReEKY'><tfoot id='ReEKY'></tfoot><dl id='ReEKY'><fieldset id='ReEKY'></fieldset></dl></div>

                          <tbody id='ReEKY'></tbody>
                        <legend id='ReEKY'><style id='ReEKY'><dir id='ReEKY'><q id='ReEKY'></q></dir></style></legend>
                        1. <small id='ReEKY'></small><noframes id='ReEKY'>

                          <tfoot id='ReEKY'></tfoot>

                          • 主站蜘蛛池模板: www.黄色av | 国产视频一区二区在线 | www.色日本| 99热99re6国产在线播放 | 三级视频在线观看 | www.精品 | 亚洲精品在 | 亚洲va视频 | 免费国产| 久久久国产视频 | 香蕉视频网站 | 天天天天躁天天爱天天碰2018 | 毛片网站免费 | 久久久精品国产sm调教网站 | 中文在线观看免费网站 | 视色av | 亚洲免费成人 | 神马福利视频 | www.嫩草| 亚洲天堂第一页 | 蜜臀av在线播放 | 亚洲国产精品久久久久久久 | 日韩视频免费在线观看 | 国产精品第一区 | 久久久精品国产sm调教 | 久久久久国产精品夜夜夜夜夜 | 3d动漫精品h区xxxxx区 | 国产激情久久久 | 黄色一区二区三区 | 日韩一区二区三区在线播放 | 成年人午夜视频 | 亚洲三级黄色片 | 天堂影院av | 国产三级视频在线 | 日韩视频免费观看 | 夜夜操av| 亚洲精品日韩丝袜精品 | 不卡的av在线 | 亚洲在线免费观看 | 91久久综合 | 官场少妇尤物雪白高耸 |