문제

When I am looping over a file using the construct below, I also want the current line number.

    with codecs.open(filename, 'rb', 'utf8' ) as f:
        retval = []
        for line in f:
            process(line)

Does something akin to this exist ?

    for line, lineno in f:

올바른 솔루션이 없습니다

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top