Python: Make file lists from current directory using a wildcard
Python Basic: Exercise-111 with Solution
Write a Python program to make file lists from current directory using a wildcard.
import glob file_list = glob.glob('*.*') print(file_list) #Specific files print(glob.glob('*.py')) print(glob.glob('./[0-9].*'))
['main.py'] ['main.py'] 
from pathlib import Path for path in Path("/").glob("*.*"): print(path)
Python Code Editor:
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
What is the difficulty level of this exercise?
Test your Python skills with w3resource's quiz
Python: Tips of the Day
try: foo() except Exception: print("Exception occured") else: print("Exception didnt occur") finally: print("Always gets here")
- New Content published on w3resource:
- Scala Programming Exercises, Practice, Solution
- Python Itertools exercises
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework