What do you want to save?
Add Code snippet
New code examples
-
Python 2022-01-28 16:30:27
python get script name
# Option 1: Works for Python 3.4 + from pathlib import Path Path(__file__).name # ScriptName.py Path(__file__).stem # ScriptName # Option 2: use `os` library import os os.path.basename(__file__) # ScriptName.py os.path.splitext(os.path.basename(... Add solution -
Python 2021-11-18 02:19:18
Find Files With a Certain Extension in the Directory and Its Subdirectories in Python
>>> import pathlib >>> fileDir = r"C:\Test" >>> fileExt = r"**\*.txt" >>> list(pathlib.Path(fileDir).glob(fileExt)) [WindowsPath('C:/Test/test.txt'), WindowsPath('C:/Test/test1.txt'), WindowsPath('C:... Add solution