mirror of
https://github.com/davrot/pytutorial.git
synced 2025-04-17 20:56:41 +02:00
Update README.md
Signed-off-by: David Rotermund <54365609+davrot@users.noreply.github.com>
This commit is contained in:
parent
c6bbdfa1df
commit
1d57978583
1 changed files with 32 additions and 0 deletions
|
@ -16,3 +16,35 @@ Path("Testfile_010.mat").touch()
|
|||
Path("Testfile_003.mat").touch()
|
||||
```
|
||||
|
||||
## Using glob in a for-loop
|
||||
|
||||
```python
|
||||
import glob
|
||||
|
||||
for filename in glob.glob("*.mat"):
|
||||
print(filename)
|
||||
```
|
||||
|
||||
```python console
|
||||
Testfile_001.mat
|
||||
Testfile_002.mat
|
||||
Testfile_010.mat
|
||||
Testfile_003.mat
|
||||
```
|
||||
|
||||
## Using glob to create a list
|
||||
|
||||
```python
|
||||
import glob
|
||||
|
||||
list = glob.glob("*.mat")
|
||||
print(list)
|
||||
```
|
||||
|
||||
```python console
|
||||
['Testfile_001.mat', 'Testfile_002.mat', 'Testfile_010.mat', 'Testfile_003.mat']
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue