question about splitting a large file

前端 未结 4 696
醉话见心
醉话见心 2021-01-26 05:37

Hey I need to split a large file in python into smaller files that contain only specific lines. How do I do this?

4条回答
  •  花落未央
    2021-01-26 06:18

    First, open the big file for reading.

    Second, open all the smaller file names for writing.

    Third, iterate through every line. Every iteration, check to see what kind of line it is, then write it to that file.

    More info on File I/O: http://docs.python.org/tutorial/inputoutput.html

提交回复
热议问题