192

Web アプリケーション用のログ ファイル ビューアーを作成しています。そのために、ログ ファイルの行をページ分けしたいと考えています。ファイル内の項目は行ベースで、最新の項目が一番下になります。

したがって、下から行tail()を読み取りn、オフセットをサポートできるメソッドが必要です。これは私が思いついた帽子です:

def tail(f, n, offset=0):
    """Reads a n lines from f with an offset of offset lines."""
    avg_line_length = 74
    to_read = n + offset
    while 1:
        try:
            f.seek(-(avg_line_length * to_read), 2)
        except IOError:
            # woops.  apparently file is smaller than what we want
            # to step back, go to the beginning instead
            f.seek(0)
        pos = f.tell()
        lines = f.read().splitlines()
        if len(lines) >= to_read or pos == 0:
            return lines[-to_read:offset and -offset or None]
        avg_line_length *= 1.3

これは合理的なアプローチですか?オフセットを使用してログ ファイルを末尾に表示するための推奨される方法は何ですか?

4

34 に答える 34

129

これはあなたよりも速いかもしれません。行の長さについては仮定しません。正しい数の「\n」文字が見つかるまで、一度に1ブロックずつファイルをさかのぼります。

def tail( f, lines=20 ):
    total_lines_wanted = lines

    BLOCK_SIZE = 1024
    f.seek(0, 2)
    block_end_byte = f.tell()
    lines_to_go = total_lines_wanted
    block_number = -1
    blocks = [] # blocks of size BLOCK_SIZE, in reverse order starting
                # from the end of the file
    while lines_to_go > 0 and block_end_byte > 0:
        if (block_end_byte - BLOCK_SIZE > 0):
            # read the last block we haven't yet read
            f.seek(block_number*BLOCK_SIZE, 2)
            blocks.append(f.read(BLOCK_SIZE))
        else:
            # file too small, start from begining
            f.seek(0,0)
            # only read what was not read
            blocks.append(f.read(block_end_byte))
        lines_found = blocks[-1].count('\n')
        lines_to_go -= lines_found
        block_end_byte -= BLOCK_SIZE
        block_number -= 1
    all_read_text = ''.join(reversed(blocks))
    return '\n'.join(all_read_text.splitlines()[-total_lines_wanted:])

実際問題として、そのようなことを決して知ることができない場合、行の長さについてのトリッキーな仮定は好きではありません。

通常、これにより、ループの1回目または2回目のパスで最後の20行が特定されます。74文字のものが実際に正確である場合、ブロックサイズを2048にすると、ほぼすぐに20行がテールになります。

また、物理的なOSブロックとの整合性を調整しようとして、脳のカロリーをあまり消費しません。これらの高レベルのI/Oパッケージを使用すると、OSブロックの境界に合わせようとするとパフォーマンスに影響が出るとは思えません。低レベルのI/Oを使用すると、スピードアップが見られる場合があります。


アップデート

Python 3.2以降の場合、テキストファイル(モード文字列に「b」を付けずに開いたもの)では、ファイルの先頭を基準にしたシークのみが許可されます(ファイルの最後までシークする場合を除く)のように、バイトでプロセスに従います。 seek(0、2))を使用します。:

例えば:f = open('C:/.../../apache_logs.txt', 'rb')

 def tail(f, lines=20):
    total_lines_wanted = lines

    BLOCK_SIZE = 1024
    f.seek(0, 2)
    block_end_byte = f.tell()
    lines_to_go = total_lines_wanted
    block_number = -1
    blocks = []
    while lines_to_go > 0 and block_end_byte > 0:
        if (block_end_byte - BLOCK_SIZE > 0):
            f.seek(block_number*BLOCK_SIZE, 2)
            blocks.append(f.read(BLOCK_SIZE))
        else:
            f.seek(0,0)
            blocks.append(f.read(block_end_byte))
        lines_found = blocks[-1].count(b'\n')
        lines_to_go -= lines_found
        block_end_byte -= BLOCK_SIZE
        block_number -= 1
    all_read_text = b''.join(reversed(blocks))
    return b'\n'.join(all_read_text.splitlines()[-total_lines_wanted:])
于 2008-09-25T21:43:18.447 に答える
99

Python2でUNIXライクなシステムを実行できると仮定します。

import os
def tail(f, n, offset=0):
  stdin,stdout = os.popen2("tail -n "+n+offset+" "+f)
  stdin.close()
  lines = stdout.readlines(); stdout.close()
  return lines[:,-offset]

Python 3の場合、次のことを行うことができます。

import subprocess
def tail(f, n, offset=0):
    proc = subprocess.Popen(['tail', '-n', n + offset, f], stdout=subprocess.PIPE)
    lines = proc.stdout.readlines()
    return lines[:, -offset]
于 2008-09-25T21:30:14.810 に答える
38

これが私の答えです。ピュアパイソン。timeit を使用すると、かなり高速に見えます。100,000 行のログ ファイルの 100 行をテーリングします。

>>> timeit.timeit('tail.tail(f, 100, 4098)', 'import tail; f = open("log.txt", "r");', number=10)
0.0014600753784179688
>>> timeit.timeit('tail.tail(f, 100, 4098)', 'import tail; f = open("log.txt", "r");', number=100)
0.00899195671081543
>>> timeit.timeit('tail.tail(f, 100, 4098)', 'import tail; f = open("log.txt", "r");', number=1000)
0.05842900276184082
>>> timeit.timeit('tail.tail(f, 100, 4098)', 'import tail; f = open("log.txt", "r");', number=10000)
0.5394978523254395
>>> timeit.timeit('tail.tail(f, 100, 4098)', 'import tail; f = open("log.txt", "r");', number=100000)
5.377126932144165

コードは次のとおりです。

import os


def tail(f, lines=1, _buffer=4098):
    """Tail a file and get X lines from the end"""
    # place holder for the lines found
    lines_found = []

    # block counter will be multiplied by buffer
    # to get the block size from the end
    block_counter = -1

    # loop until we find X lines
    while len(lines_found) < lines:
        try:
            f.seek(block_counter * _buffer, os.SEEK_END)
        except IOError:  # either file is too small, or too many lines requested
            f.seek(0)
            lines_found = f.readlines()
            break

        lines_found = f.readlines()

        # we found enough lines, get out
        # Removed this line because it was redundant the while will catch
        # it, I left it for history
        # if len(lines_found) > lines:
        #    break

        # decrement the block counter to get the
        # next X bytes
        block_counter -= 1

    return lines_found[-lines:]
于 2012-12-09T18:21:42.133 に答える
35

ファイル全体の読み取りが許容できる場合は、dequeを使用します。

from collections import deque
deque(f, maxlen=n)

2.6より前のバージョンでは、dequesにはmaxlenオプションがありませんでしたが、実装は簡単です。

import itertools
def maxque(items, size):
    items = iter(items)
    q = deque(itertools.islice(items, size))
    for item in items:
        del q[0]
        q.append(item)
    return q

ファイルを最後から読み取る必要がある場合は、ギャロップ(別名指数)検索を使用します。

def tail(f, n):
    assert n >= 0
    pos, lines = n+1, []
    while len(lines) <= n:
        try:
            f.seek(-pos, 2)
        except IOError:
            f.seek(0)
            break
        finally:
            lines = list(f)
        pos *= 2
    return lines[-n:]
于 2008-11-11T05:17:18.083 に答える
26

上記のS.Lottの答えはほとんど私にとってはうまくいきますが、最終的には部分的な行になります。データが読み取りブロックを逆の順序で保持しているため、ブロック境界でデータが破損していることが判明しました。''.join(data) が呼び出されると、ブロックの順序が正しくありません。これはそれを修正します。

def tail(f, window=20):
    """
    Returns the last `window` lines of file `f` as a list.
    f - a byte file-like object
    """
    if window == 0:
        return []
    BUFSIZ = 1024
    f.seek(0, 2)
    bytes = f.tell()
    size = window + 1
    block = -1
    data = []
    while size > 0 and bytes > 0:
        if bytes - BUFSIZ > 0:
            # Seek back one whole BUFSIZ
            f.seek(block * BUFSIZ, 2)
            # read BUFFER
            data.insert(0, f.read(BUFSIZ))
        else:
            # file too small, start from begining
            f.seek(0,0)
            # only read what was not read
            data.insert(0, f.read(bytes))
        linesFound = data[0].count('\n')
        size -= linesFound
        bytes -= BUFSIZ
        block -= 1
    return ''.join(data).splitlines()[-window:]
于 2011-08-13T00:43:38.617 に答える
23

私が最終的に使用したコード。私はこれが今のところ最高だと思います:

def tail(f, n, offset=None):
    """Reads a n lines from f with an offset of offset lines.  The return
    value is a tuple in the form ``(lines, has_more)`` where `has_more` is
    an indicator that is `True` if there are more lines in the file.
    """
    avg_line_length = 74
    to_read = n + (offset or 0)

    while 1:
        try:
            f.seek(-(avg_line_length * to_read), 2)
        except IOError:
            # woops.  apparently file is smaller than what we want
            # to step back, go to the beginning instead
            f.seek(0)
        pos = f.tell()
        lines = f.read().splitlines()
        if len(lines) >= to_read or pos == 0:
            return lines[-to_read:offset and -offset or None], \
                   len(lines) > to_read or pos > 0
        avg_line_length *= 1.3
于 2009-03-28T11:13:44.380 に答える
14

mmap を使用したシンプルで高速なソリューション:

import mmap
import os

def tail(filename, n):
    """Returns last n lines from the filename. No exception handling"""
    size = os.path.getsize(filename)
    with open(filename, "rb") as f:
        # for Windows the mmap parameters are different
        fm = mmap.mmap(f.fileno(), 0, mmap.MAP_SHARED, mmap.PROT_READ)
        try:
            for i in xrange(size - 1, -1, -1):
                if fm[i] == '\n':
                    n -= 1
                    if n == -1:
                        break
            return fm[i + 1 if i else 0:].splitlines()
        finally:
            fm.close()
于 2011-07-25T09:18:10.030 に答える
5

同じ手法を使用してファイルの最後の行を変更するだけでなく、ファイルの最後の行を変更する同様の質問に対する私の回答に対するコメント投稿者の要請で回答を投稿しました。

かなりのサイズのファイルの場合、mmapこれを行う最善の方法です。既存の回答を改善するためにmmap、このバージョンは Windows と Linux の間で移植可能であり、より高速に実行する必要があります (GB 範囲のファイルを使用する 32 ビット Python でいくつかの変更を加えないと動作しませんが、これを処理するためのヒントについては他の回答を参照してください)。 、および Python で動作するように変更する場合 2 )。

import io  # Gets consistent version of open for both Py2.7 and Py3.x
import itertools
import mmap

def skip_back_lines(mm, numlines, startidx):
    '''Factored out to simplify handling of n and offset'''
    for _ in itertools.repeat(None, numlines):
        startidx = mm.rfind(b'\n', 0, startidx)
        if startidx < 0:
            break
    return startidx

def tail(f, n, offset=0):
    # Reopen file in binary mode
    with io.open(f.name, 'rb') as binf, mmap.mmap(binf.fileno(), 0, access=mmap.ACCESS_READ) as mm:
        # len(mm) - 1 handles files ending w/newline by getting the prior line
        startofline = skip_back_lines(mm, offset, len(mm) - 1)
        if startofline < 0:
            return []  # Offset lines consumed whole file, nothing to return
            # If using a generator function (yield-ing, see below),
            # this should be a plain return, no empty list

        endoflines = startofline + 1  # Slice end to omit offset lines

        # Find start of lines to capture (add 1 to move from newline to beginning of following line)
        startofline = skip_back_lines(mm, n, startofline) + 1

        # Passing True to splitlines makes it return the list of lines without
        # removing the trailing newline (if any), so list mimics f.readlines()
        return mm[startofline:endoflines].splitlines(True)
        # If Windows style \r\n newlines need to be normalized to \n, and input
        # is ASCII compatible, can normalize newlines with:
        # return mm[startofline:endoflines].replace(os.linesep.encode('ascii'), b'\n').splitlines(True)

これは、末尾の行数が十分に少なく、一度にすべてを安全にメモリに読み込むことができることを前提としています。これをジェネレーター関数にして、最後の行を次のように置き換えることで、一度に 1 行ずつ手動で読み取ることもできます。

        mm.seek(startofline)
        # Call mm.readline n times, or until EOF, whichever comes first
        # Python 3.2 and earlier:
        for line in itertools.islice(iter(mm.readline, b''), n):
            yield line

        # 3.3+:
        yield from itertools.islice(iter(mm.readline, b''), n)

最後に、これはバイナリモードで読み取られるため ( を使用する必要がありますmmap)、str行 (Py2) とbytes行 (Py3) が得られます。unicode(Py2)または(Py3)が必要な場合strは、反復アプローチを微調整して、デコードおよび/または改行を修正できます。

        lines = itertools.islice(iter(mm.readline, b''), n)
        if f.encoding:  # Decode if the passed file was opened with a specific encoding
            lines = (line.decode(f.encoding) for line in lines)
        if 'b' not in f.mode:  # Fix line breaks if passed file opened in text mode
            lines = (line.replace(os.linesep, '\n') for line in lines)
        # Python 3.2 and earlier:
        for line in lines:
            yield line
        # 3.3+:
        yield from lines

注: テストする Python にアクセスできないマシンで、これをすべて入力しました。何かタイプミスがあれば教えてください。これは私の他の回答と十分に似ていたので、うまくいくと思いますが、微調整( の処理などoffset)により微妙なエラーが発生する可能性があります。間違い等ありましたらコメントにてお知らせください。

于 2015-12-01T20:34:50.440 に答える
5

@papercrane ソリューションを python3 に更新します。次のコマンドを使用してファイルを開きますopen(filename, 'rb')

def tail(f, window=20):
    """Returns the last `window` lines of file `f` as a list.
    """
    if window == 0:
        return []

    BUFSIZ = 1024
    f.seek(0, 2)
    remaining_bytes = f.tell()
    size = window + 1
    block = -1
    data = []

    while size > 0 and remaining_bytes > 0:
        if remaining_bytes - BUFSIZ > 0:
            # Seek back one whole BUFSIZ
            f.seek(block * BUFSIZ, 2)
            # read BUFFER
            bunch = f.read(BUFSIZ)
        else:
            # file too small, start from beginning
            f.seek(0, 0)
            # only read what was not read
            bunch = f.read(remaining_bytes)

        bunch = bunch.decode('utf-8')
        data.insert(0, bunch)
        size -= bunch.count('\n')
        remaining_bytes -= BUFSIZ
        block -= 1

    return ''.join(data).splitlines()[-window:]
于 2017-08-30T12:40:01.197 に答える
2

上記のPopenが最良の解決策であることがわかりました。それは速くて汚いですそしてそれは動作しますUnixマシン上のpython2.6のために私は以下を使用しました

def GetLastNLines(self, n, fileName):
    """
    Name:           Get LastNLines
    Description:        Gets last n lines using Unix tail
    Output:         returns last n lines of a file
    Keyword argument:
    n -- number of last lines to return
    filename -- Name of the file you need to tail into
    """
    p = subprocess.Popen(['tail','-n',str(n),self.__fileName], stdout=subprocess.PIPE)
    soutput, sinput = p.communicate()
    return soutput

soutputには、コードの最後のn行が含まれます。行ごとにsoutputを反復処理するには、次のようにします。

for line in GetLastNLines(50,'myfile.log').split('\n'):
    print line
于 2012-04-16T13:26:32.587 に答える
2

pip を使用してインストールできる pypi の tail の既存の実装がいくつかあります。

  • mtFileUtil
  • マルチテイル
  • log4tailer
  • ...

状況によっては、これらの既存のツールのいずれかを使用する利点がある場合があります。

于 2012-10-06T18:23:37.210 に答える
2

S.Lott の上位投票の回答 (2008 年 9 月 25 日 21:43) に基づいていますが、小さなファイル用に修正されています。

def tail(the_file, lines_2find=20):  
    the_file.seek(0, 2)                         #go to end of file
    bytes_in_file = the_file.tell()             
    lines_found, total_bytes_scanned = 0, 0
    while lines_2find+1 > lines_found and bytes_in_file > total_bytes_scanned: 
        byte_block = min(1024, bytes_in_file-total_bytes_scanned)
        the_file.seek(-(byte_block+total_bytes_scanned), 2)
        total_bytes_scanned += byte_block
        lines_found += the_file.read(1024).count('\n')
    the_file.seek(-total_bytes_scanned, 2)
    line_list = list(the_file.readlines())
    return line_list[-lines_2find:]

    #we read at least 21 line breaks from the bottom, block by block for speed
    #21 to ensure we don't get a half line

これが役に立つことを願っています。

于 2010-06-10T21:28:20.193 に答える
2

単純 :

with open("test.txt") as f:
data = f.readlines()
tail = data[-2:]
print(''.join(tail)
于 2019-05-15T03:51:54.393 に答える
1

非常に大きなファイル(テールを使用する可能性のあるログファイルの状況で一般的)を効率化するために、通常はファイル全体を読み取らないようにします(ファイル全体を一度にメモリに読み込まずに実行する場合でも)。文字ではなく行のオフセットをどうにかして計算する必要があります。1つの可能性は、seek()charをcharごとに逆方向に読み取ることですが、これは非常に低速です。代わりに、より大きなブロックで処理する方が適切です。

ここで使用できるファイルを逆方向​​に読み取るために、少し前に作成したユーティリティ関数があります。

import os, itertools

def rblocks(f, blocksize=4096):
    """Read file as series of blocks from end of file to start.

    The data itself is in normal order, only the order of the blocks is reversed.
    ie. "hello world" -> ["ld","wor", "lo ", "hel"]
    Note that the file must be opened in binary mode.
    """
    if 'b' not in f.mode.lower():
        raise Exception("File must be opened using binary mode.")
    size = os.stat(f.name).st_size
    fullblocks, lastblock = divmod(size, blocksize)

    # The first(end of file) block will be short, since this leaves 
    # the rest aligned on a blocksize boundary.  This may be more 
    # efficient than having the last (first in file) block be short
    f.seek(-lastblock,2)
    yield f.read(lastblock)

    for i in range(fullblocks-1,-1, -1):
        f.seek(i * blocksize)
        yield f.read(blocksize)

def tail(f, nlines):
    buf = ''
    result = []
    for block in rblocks(f):
        buf = block + buf
        lines = buf.splitlines()

        # Return all lines except the first (since may be partial)
        if lines:
            result.extend(lines[1:]) # First line may not be complete
            if(len(result) >= nlines):
                return result[-nlines:]

            buf = lines[0]

    return ([buf]+result)[-nlines:]


f=open('file_to_tail.txt','rb')
for line in tail(f, 20):
    print line

[編集]より具体的なバージョンを追加しました(2回反転する必要はありません)

于 2008-09-25T21:40:32.557 に答える
1

Eyecue の回答 (10 年 6 月 10 日 21:28) に基づく: このクラスは、ファイル オブジェクトに head() および tail() メソッドを追加します。

class File(file):
    def head(self, lines_2find=1):
        self.seek(0)                            #Rewind file
        return [self.next() for x in xrange(lines_2find)]

    def tail(self, lines_2find=1):  
        self.seek(0, 2)                         #go to end of file
        bytes_in_file = self.tell()             
        lines_found, total_bytes_scanned = 0, 0
        while (lines_2find+1 > lines_found and
               bytes_in_file > total_bytes_scanned): 
            byte_block = min(1024, bytes_in_file-total_bytes_scanned)
            self.seek(-(byte_block+total_bytes_scanned), 2)
            total_bytes_scanned += byte_block
            lines_found += self.read(1024).count('\n')
        self.seek(-total_bytes_scanned, 2)
        line_list = list(self.readlines())
        return line_list[-lines_2find:]

使用法:

f = File('path/to/file', 'r')
f.head(3)
f.tail(3)
于 2011-01-20T19:29:37.357 に答える
1

これは非常に単純な実装です。

with open('/etc/passwd', 'r') as f:
  try:
    f.seek(0,2)
    s = ''
    while s.count('\n') < 11:
      cur = f.tell()
      f.seek((cur - 10))
      s = f.read(10) + s
      f.seek((cur - 10))
    print s
  except Exception as e:
    f.readlines()
于 2016-06-19T01:54:08.593 に答える
1

f.seek(0, 2) を使用してファイルの最後に移動し、readline() を次のように置き換えて、行を 1 つずつ読み取ることができます。

def readline_backwards(self, f):
    backline = ''
    last = ''
    while not last == '\n':
        backline = last + backline
        if f.tell() <= 0:
            return backline
        f.seek(-1, 1)
        last = f.read(1)
        f.seek(-1, 1)
    backline = last
    last = ''
    while not last == '\n':
        backline = last + backline
        if f.tell() <= 0:
            return backline
        f.seek(-1, 1)
        last = f.read(1)
        f.seek(-1, 1)
    f.seek(1, 1)
    return backline
于 2010-11-09T06:50:09.913 に答える
1

これらのソリューションのいくつかは、ファイルが \n で終わっていない場合、または最初の行が完全に読み取られることを確認する際に問題があります。

def tail(file, n=1, bs=1024):
    f = open(file)
    f.seek(-1,2)
    l = 1-f.read(1).count('\n') # If file doesn't end in \n, count it anyway.
    B = f.tell()
    while n >= l and B > 0:
            block = min(bs, B)
            B -= block
            f.seek(B, 0)
            l += f.read(block).count('\n')
    f.seek(B, 0)
    l = min(l,n) # discard first (incomplete) line if l > n
    lines = f.readlines()[-l:]
    f.close()
    return lines
于 2011-04-12T16:14:42.537 に答える
1

A.Coadyによる回答の更新

Python 3で動作します。

これはExponential Searchを使用し、後方からの行のみをバッファリングするためN、非常に効率的です。

import time
import os
import sys

def tail(f, n):
    assert n >= 0
    pos, lines = n+1, []

    # set file pointer to end

    f.seek(0, os.SEEK_END)

    isFileSmall = False

    while len(lines) <= n:
        try:
            f.seek(f.tell() - pos, os.SEEK_SET)
        except ValueError as e:
            # lines greater than file seeking size
            # seek to start
            f.seek(0,os.SEEK_SET)
            isFileSmall = True
        except IOError:
            print("Some problem reading/seeking the file")
            sys.exit(-1)
        finally:
            lines = f.readlines()
            if isFileSmall:
                break

        pos *= 2

    print(lines)

    return lines[-n:]




with open("stream_logs.txt") as f:
    while(True):
        time.sleep(0.5)
        print(tail(f,2))

于 2019-07-30T17:37:10.253 に答える
0
import time

attemps = 600
wait_sec = 5
fname = "YOUR_PATH"

with open(fname, "r") as f:
    where = f.tell()
    for i in range(attemps):
        line = f.readline()
        if not line:
            time.sleep(wait_sec)
            f.seek(where)
        else:
            print line, # already has newline
于 2014-08-22T15:52:53.540 に答える
0

両端キューを使用した最初の例ではなく、より単純な例です。これは一般的なものです。ファイルだけでなく、反復可能なオブジェクトで機能します。

#!/usr/bin/env python
import sys
import collections
def tail(iterable, N):
    deq = collections.deque()
    for thing in iterable:
        if len(deq) >= N:
            deq.popleft()
        deq.append(thing)
    for thing in deq:
        yield thing
if __name__ == '__main__':
    for line in tail(sys.stdin,10):
        sys.stdout.write(line)
于 2013-05-12T12:38:55.377 に答える
0

ファイルの最後の行から特定の値を読み取る必要があり、このスレッドに出くわしました。Python で車輪を再発明するのではなく、/usr/local/bin/get_last_netp として保存された小さなシェル スクリプトに行き着きました。

#! /bin/bash
tail -n1 /home/leif/projects/transfer/export.log | awk {'print $14'}

Python プログラムでは、次のようになります。

from subprocess import check_output

last_netp = int(check_output("/usr/local/bin/get_last_netp"))
于 2013-05-12T12:11:01.107 に答える
0
abc = "2018-06-16 04:45:18.68"
filename = "abc.txt"
with open(filename) as myFile:
    for num, line in enumerate(myFile, 1):
        if abc in line:
            lastline = num
print "last occurance of work at file is in "+str(lastline) 
于 2018-06-17T06:40:53.000 に答える
0
This is my version of tailf

import sys, time, os

filename = 'path to file'

try:
    with open(filename) as f:
        size = os.path.getsize(filename)
        if size < 1024:
            s = size
        else:
            s = 999
        f.seek(-s, 2)
        l = f.read()
        print l
        while True:
            line = f.readline()
            if not line:
                time.sleep(1)
                continue
            print line
except IOError:
    pass
于 2014-04-25T10:24:36.673 に答える
-1

よく考えてみると、これはおそらくここにあるものと同じくらい高速です。

def tail( f, window=20 ):
    lines= ['']*window
    count= 0
    for l in f:
        lines[count%window]= l
        count += 1
    print lines[count%window:], lines[:count%window]

それはずっと簡単です。そして、それは良いペースで引き裂かれているようです。

于 2008-09-25T22:03:09.833 に答える