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

18 lines
419 B
Python
Raw Normal View History

# -*- coding: utf-8 -*-
from __future__ import absolute_import
2017-07-23 05:32:18 +00:00
from .word_count import search, search_sequential
__all__ = ['search', 'search_sequential', 'search_py']
def search_py(path, needle):
total = 0
with open(path, 'r') as f:
for line in f:
words = line.split(' ')
for word in words:
if word == needle:
total += 1
return total