Created
December 20, 2021 16:19
-
-
Save jaimealves/4adfb27345c6b0de099fc36ecc098a48 to your computer and use it in GitHub Desktop.
Sorted glob
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # armazenar o nome dos arquivos | |
| glob_results = glob.glob('*.txt') | |
| # para se obter resultado do glob em ordem alfabetica dos nomes dos arquivos | |
| print(sorted(glob_results)) | |
| # para se obter resultado do glob em ordem de tamanho dos arquivos | |
| print(sorted(glob_results, key=os.path.getsize)) | |
| # fonte: https://www.kite.com/python/answers/how-to-sort-the-results-of-the-glob-function-in-python |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment