0
短重命名/對Web服務器固定記錄模塊......當我做了list.sort(),列表中的條目得到安置順序如下:蟒蛇排序列表
2011-09-21 19:15:54,731 DEBUG __main__ 44: running www.site.com-110731.log.0.gz
2011-09-21 19:15:54,731 DEBUG __main__ 44: running www.site.com-110731.log.1.gz
2011-09-21 19:15:54,731 DEBUG __main__ 44: running www.site.com-110731.log.2.gz
2011-09-21 19:15:54,732 DEBUG __main__ 44: running www.site.com-110731.log.3.gz
2011-09-21 19:15:54,732 DEBUG __main__ 44: running www.site.com-110731.log.gz
我會怎樣排序列表,以獲得(即eithout一個數字條目是第一個):
2011-09-21 19:15:54,732 DEBUG __main__ 44: running www.site.com-110731.log.gz
2011-09-21 19:15:54,731 DEBUG __main__ 44: running www.site.com-110731.log.0.gz
2011-09-21 19:15:54,731 DEBUG __main__ 44: running www.site.com-110731.log.1.gz
2011-09-21 19:15:54,731 DEBUG __main__ 44: running www.site.com-110731.log.2.gz
2011-09-21 19:15:54,732 DEBUG __main__ 44: running www.site.com-110731.log.3.gz
THANKS !!!!!!!!!!!!!!!!!!!!!!!! !!!!!!
嗯...我知道110701.log.gz總是會先,然後是.log.1.gz .log.2.gz等 – Cmag
這是一個關閉袖口,但似乎工作作爲你似乎打算。如果這是「嚴肅的商業」,你應該在'extract'之外編譯正則表達式。 –
啊,我錯過了最後一個例子!我會編輯'extract'。 –