files.py 345 B

12345678910111213
  1. from os import listdir, getcwd
  2. from os.path import isfile, join, basename
  3. def get_txt_files():
  4. path = getcwd() + "/files"
  5. try:
  6. onlyfiles = [f"{path}/{f}" for f in listdir(path) if isfile(join(path, f)) \
  7. and f.lower().endswith('.txt')]
  8. except Exception as err:
  9. print(f'files10 ERR \n{err}')
  10. return []
  11. return onlyfiles