If you want to ignore lines with only whitespace:
if line.strip():
... do something
The empty string is a False value.
Or if you really want only empty lines:
if line in ['\n', '\r\n']:
... do something
More Related Contents:
- How do I create a scoring system in Python? [closed]
- Strange result when removing item from a list while iterating over it
- How do I execute a string containing Python code in Python?
- Why is __init__() always called after __new__()?
- What is related_name used for?
- How to read multiple lines of raw input?
- How to change backends in matplotlib / Python
- Is it safe to replace a self object by another object of the same type in a method?
- multiprocessing.Pool: What’s the difference between map_async and imap?
- How to redirect stdout to both file and console with scripting?
- Difference between “findAll” and “find_all” in BeautifulSoup
- How to create an object for a Django model with a many to many field?
- ValueError: could not broadcast input array from shape (224,224,3) into shape (224,224)
- Real world example about how to use property feature in python?
- numpy array concatenate: “ValueError: all the input arrays must have same number of dimensions”
- Add commas into number string [duplicate]
- How to explode multiple columns of a dataframe in pyspark
- Mark data as sensitive in python
- How to make a query date in mongodb using pymongo?
- Why do I get “Pickle – EOFError: Ran out of input” reading an empty file?
- How can I solve equations in Python? [closed]
- Transfer file from URL to Cloud Storage
- How to monkeypatch python’s datetime.datetime.now with py.test?
- Python split list into n chunks
- CSRF verification failed. Request aborted
- How can I add textures to my bars and wedges?
- Add column of empty lists to DataFrame
- Can’t sort my list because it is NoneType? Simple Python [duplicate]
- Remove consecutive duplicates in a NumPy array
- Import statement works on PyCharm but not from terminal