Use Python Standard Library’s linecache module:
line = linecache.getline(thefilename, 33)
should do exactly what you want. You don’t even need to open the file — linecache
does it all for you!
More Related Contents:
- Please explain the working of this code? [closed]
- Remove all occurrences of a value from a list?
- How to detect key presses?
- How are POST and GET variables handled in Python?
- Python memory leaks [closed]
- Getting an instance name inside class __init__() [duplicate]
- How many concurrent requests does a single Flask process receive?
- How to pass an operator to a python function?
- How to create a density plot in matplotlib?
- Convert spreadsheet number to column letter
- error: [Errno 10053]
- Python Argparse conditionally required arguments
- Passing a function to re.sub in Python
- Read password from stdin [duplicate]
- Python: filter list of list with another list
- Why does Python return negative list indexes?
- Google search using python script [closed]
- How to send image generated by PIL to browser?
- function is not defined error in Python
- Python saving multiple figures into one PDF file
- Do properties work on Django model fields?
- Python: is the current directory automatically included in path?
- Get first row of dataframe in Python Pandas based on criteria
- Pandas read_csv dtype read all columns but few as string
- finding last business day of a month in python
- Send method using generator. still trying to understand the send method and quirky behaviour
- Weird MRO result when inheriting directly from typing.NamedTuple
- pycairo “ImportError: DLL load failed: The specified module could not be found.” even after DLLs installed
- What is this odd sorting algorithm?
- Get weekday/day-of-week for Datetime column of DataFrame