Skip to content

Instantly share code, notes, and snippets.

@flow2k
Created May 29, 2019 06:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save flow2k/8bd4fece21fa1a0b75737a3d9fc2e86c to your computer and use it in GitHub Desktop.
Save flow2k/8bd4fece21fa1a0b75737a3d9fc2e86c to your computer and use it in GitHub Desktop.
numBads = 0
with open(filename, encoding="utf-8", errors="strict") as f:
while True:
try:
line = f.readline()
if not line:
break
print(line)
except UnicodeDecodeError:
numBads += 1
continue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment