Différences
Ci-dessous, les différences entre deux révisions de la page.
| Les deux révisions précédentes Révision précédente Prochaine révision | Révision précédente | ||
| python:filesystem [2022/02/15 13:14] – add how to strip extension from filename phsw | python:filesystem [2024/03/27 10:23] (Version actuelle) – add how to create temporary file phsw | ||
|---|---|---|---|
| Ligne 17: | Ligne 17: | ||
| filepath = "/ | filepath = "/ | ||
| - | os.path.firname(filepath) # "/ | + | os.path.dirname(filepath) # "/ |
| </ | </ | ||
| Ligne 141: | Ligne 141: | ||
| print(os.path.splitext("/ | print(os.path.splitext("/ | ||
| </ | </ | ||
| + | |||
| + | |||
| + | ==== Fichiers temporaires ==== | ||
| + | |||
| + | Utilise l' | ||
| + | <code python> | ||
| + | from tempfile import NamedTemporaryFile | ||
| + | |||
| + | f = NamedTemporaryFile(mode=" | ||
| + | f.write(" | ||
| + | f.close() | ||
| + | print(f" | ||
| + | </ | ||
| + | |||