pyo3/examples/word-count/word_count/__init__.py

15 lines
351 B
Python
Raw Normal View History

2018-07-30 20:52:22 +00:00
from .word_count import WordCounter, count_line
2018-07-30 20:52:22 +00:00
__all__ = ["WordCounter", "count_line", "search_py"]
def search_py(path, needle):
total = 0
2018-07-30 20:52:22 +00:00
with open(path, "r") as f:
for line in f:
2018-07-30 20:52:22 +00:00
words = line.split(" ")
for word in words:
if word == needle:
total += 1
return total