- import subprocess
- c=subprocess.getoutput('ls')
- r=[a for a in c.split() if 'chat' in a.lower()]
- print(r)
- c
- ['chatbot.py', 'ChatGPT.pdf']
- looking from a list will search all mp3 and mp4 and pdf file and will return a list with sub list for each category
- >>> [[a for a in c.split() if d.lower() in a.lower()] for d in ['mp3','mp4','pdf']]
- [['1.mp3', 'output.mp3', 'tts_1.mp3'], ['pp.mp4'], ['ChatGPT.pdf', 'PDF']]
No hay comentarios:
Publicar un comentario