How To Check If File Contains String With Python
Mar 14, 2022
The aim of this page📝 is for checking for a string in python which is a combination of the 3 built-in methods. I am using this when unit-testing the functionality of logging. This is the pattern:
open('<FILENAME>', 'r').read().find('<STRING>')
- See str.find(sub[, start[, end]]) < Built-in Types < Python documentation
- The value is stream position pointer