python read single line from file as string -


i have text file bunch of numbers line of numbers , , etc. n number of lines

how can read , store lines n number of strings?

from docs.

or specifically:

file.readline([size])

read 1 entire line file. trailing newline character kept in string (but may absent when file ends incomplete line). [6] if size argument present , non-negative, maximum byte count (including trailing newline) , incomplete line may returned. when size not 0, empty string returned when eof encountered immediately.

file.readlines([sizehint])

read until eof using readline() , return list containing lines read. if optional sizehint argument present, instead of reading eof, whole lines totalling approximately sizehint bytes (possibly after rounding internal buffer size) read. objects implementing file-like interface may choose ignore sizehint if cannot implemented, or cannot implemented efficiently.


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -