久久久久久久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 中合并和排序日志文件的處理方法,對(duì)大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                  問題描述

                  我對(duì) python 完全陌生,但我遇到了一個(gè)無法解決的嚴(yán)重問題.

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

                  我有幾個(gè)結(jié)構(gòu)相同的日志文件:

                  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 編寫一個(gè)程序,它將這些日志文件合并到一個(gè)文件中,然后按時(shí)間戳對(duì)合并后的文件進(jìn)行排序.在此操作之后,我希望將此結(jié)果(合并文件的內(nèi)容)打印到 STDOUT(控制臺(tái)).

                  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,
                  

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

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

                  相關(guān)文檔推薦

                  python: Two modules and classes with the same name under different packages(python:不同包下同名的兩個(gè)模塊和類)
                  Configuring Python to use additional locations for site-packages(配置 Python 以使用站點(diǎn)包的其他位置)
                  How to structure python packages without repeating top level name for import(如何在不重復(fù)導(dǎo)入頂級(jí)名稱的情況下構(gòu)造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(分發(fā)帶有已編譯動(dòng)態(tài)共享庫(kù)的 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>

                          • 主站蜘蛛池模板: 亚洲精品4 | 欧美成人一区二区三区 | 99一区二区| 日韩成人在线观看 | 日韩高清国产一区在线 | av在线一区二区三区 | 成人在线视频免费播放 | 日韩在线不卡 | 日韩精品一区二区三区中文字幕 | 日本高清中文字幕 | 网站国产| 国产免费一区 | 懂色中文一区二区三区在线视频 | 久久精品免费一区二区三 | 嫩草伊人| 日韩在线观看中文字幕 | 91精品国产综合久久精品图片 | 日本一区二区三区精品视频 | 黄色一级电影在线观看 | 国产成人精品一区二区三区 | 成人av影院| 国产欧美一区二区三区另类精品 | 成人免费视频网 | 99久久精品国产一区二区三区 | 在线成人精品视频 | 看片地址 | 精品一二区 | 欧美一区二区免费 | 毛片区| 久久精品中文 | 国产精品亚洲第一区在线暖暖韩国 | 欧美日韩在线视频观看 | 久久精品亚洲国产奇米99 | 九九av| 天天干亚洲| 国产免费看 | 欧美成视频在线观看 | 久久中文一区二区 | 久久精品视频播放 | 中文字幕国产第一页 | 国产一区二区免费在线 |