Hello. How to do brute force files in python? - And if it finds a string that says Hello world! - then some logic will be executed.
I am an absolute beginner, but for me it is very important to solve this problem. I do not know where to start.
I don’t ask all the code, although it would be a piece that will guide the solution.
pathlib.Path.cwd().rglob("*.txt")finds all txt files in the current directory tree (recursively). 2- what does "find the string" mean? Whole line? Or is it enough to match a substring? What if a substring occurs several times in a single "\ n" string? In one file? What do you want to pass as an argument for the action? 3- the question of getting a list of files and the question of searching within a single file is better (more useful for other visitors to the site) separately set (for the context you can give a link - jfs