How do I iterate over all lines of files passed on the command line?

后端 未结 5 1793
温柔的废话
温柔的废话 2021-02-04 02:54

I usually do this in Perl:

whatever.pl

while(<>) {
    #do whatever;
}

then cat foo.txt | whatever.pl

Now, I

5条回答
  •  庸人自扰
    2021-02-04 03:33

    import sys
    def main():
        for line in sys.stdin:
            print line
    if __name__=='__main__':
        sys.exit(main())
    

提交回复
热议问题