python - A size of a data that actually was read -


i read part of file:

size_to_read = 999999 open(file_name, "r") f:   read_part = f.read(size_to_read) 

how know size of data (read_part) read in case if size of file less size_to_read?

simply check length of string built in len function:

size_to_read = 999999   open(file_name, "r") f:     read_part = f.read(size_to_read)     if(not len(read_part) == size_to_read):     eol_reached_unexpectedly() 

Comments

Popular posts from this blog

assembly - 8086 TASM: Illegal Indexing Mode -

Java, LWJGL, OpenGL 1.1, decoding BufferedImage to Bytebuffer and binding to OpenGL across classes -

javascript - addthis share facebook and google+ url -