in_file.seek(-10, 2) # where 2 denotes the reference point being the end of the file
So then:
in_file = open("demofile.txt", "rb") # opening for [r]eading as [b]inary
in_file.seek(-10, 2)
s = in_file.read(10)
print(s)
OUTPUT:
b'Good Luck!'
More Related Contents:
- Adding a element in dictionary which consist of dictionaries.
- Select nan column in pandas
- Sorting list based on values from another list
- How to make Firefox headless programmatically in Selenium with Python?
- Matplotlib scatterplot; color as a function of a third variable
- Usage of sys.stdout.flush() method
- How to calculate the sum of all columns of a 2D numpy array (efficiently)
- Time complexity of python set operations?
- Is there a generator version of `string.split()` in Python?
- What is the correct way to set Python’s locale on Windows?
- Calling functions from a Tkinter Frame to another
- Render NumPy array in FastAPI
- How to create a hyperlink with a Label in Tkinter?
- Django: CSRF token missing or incorrect
- Dimension of shape in conv1D
- UnicodeDecodeError: (‘utf-8’ codec) while reading a csv file [duplicate]
- mechanize python click a button
- Determine the common prefix of multiple strings
- How can I register a single view (not a viewset) on my router?
- How to multiply two 2D RFFT arrays (FFTPACK) to be compatible with NumPy’s FFT?
- pytest using fixtures as arguments in parametrize
- pandas filling nans by mean of before and after non-nan values
- How to handle non-determinism when training on a GPU?
- make pandas DataFrame to a dict and dropna
- syntaxError: ‘continue’ not properly in loop
- wxPython: Calling an event manually
- WinError 10049: The requested address is not valid in its context
- Save plot to numpy array
- How to set the ‘equal’ aspect ratio for all axes (x, y, z)
- VALUES clause in SQLAlchemy