Skip to content

Commit

Permalink
new tip
Browse files Browse the repository at this point in the history
  • Loading branch information
bbelderbos committed Jul 11, 2024
1 parent b4e1274 commit 89dd46e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions index.md
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,7 @@ This file gets generated by [this script](index.py).
- [Pathlib home and cwd](notes/20220904163710.md)
- [Pathlib list files in directory](notes/20220904164101.md)
- [Read / write files the modern way](notes/20221202131250.md)
- [Split file name and extension](notes/20240711112258.md)

## Pdf

Expand Down
14 changes: 14 additions & 0 deletions notes/20240711112258.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# split file name and extension

`pathlib` has you covered, just make a `Path` object and access the `stem` and `suffix` attributes:

```
import pathlib
path = pathlib.Path('20240711112258.md')
print(path.stem) # 20240711112258
print(path.suffix) # .md
```

#pathlib

0 comments on commit 89dd46e

Please sign in to comment.