Nov-03-2020, 01:52 PM
my_string = "hello\nthere" print(my_string) start_index = my_string.find("ello") print(start_index) start_index = my_string.find("x") print(start_index)Opening files in text-mode for reading: https://docs.python.org/3/library/functions.html#open
Together with Context-Manager: https://realpython.com/working-with-file...as-pattern
All together in a function:
def has_pattern(file, pattern): with open(file, encoding="utf8") as fd: # inside this block the file is open for reading # read content -> find pattern -> return result_of_pattern != -1 return fd.read().find(pattern) != -1
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
All humans together. We don't need politicians!