Answers for "python search for string in file"

2

python search for string in file

with open('example.txt') as f:
    if 'blabla' in f.read():
        print("true")
Posted by: Guest on February-14-2021
-1

python : search file for string

import mmap

with open('example.txt') as f:
    s = mmap.mmap(f.fileno(), 0, access=mmap.ACCESS_READ)
    if s.find('blabla') != -1:
        print('true')
Posted by: Guest on September-25-2021

Code answers related to "python search for string in file"

Python Answers by Framework

Browse Popular Code Answers by Language