Regardless of how basic this task seems to be I am struggling to read a specific line of a file in Python.
I am creating a quotation system for reading and writing files is a key part. In the code the line which needs to get read needs to correspond to a place value predefined by the variable Position
. I then want the line to be stored to a variable.
I am trying to look for an efficient way where you don't have to go through the whole file. I have tried using file.readline(Position)
but that keeps displaying 0. I have included parts of my code for context.
value = self.option.get()
Position= int(array.index(value))
print(value) #test
print(Position) #test
file= open("Height_File.txt", "r")
Height= file.readline(Position)
print(Height)#test
file.close()