Reading in a text file in a set line range

前端 未结 3 1402
暗喜
暗喜 2020-12-15 01:16

Is it possible to read in from a text file a set line range for example from line 20 to 52?

I am opening the file and reading the file like this:

te         


        
3条回答
  •  -上瘾入骨i
    2020-12-15 01:47

    HM,you can try something with while loop....but you should know up to which string you want text to be loaded,which is not best way:

    text_file=open(name,'r')
    line=text.readline()
    while line!=(" ") #type the line where you want it to stop
    print (line
    

提交回复
热议问题