How do I append a string to a Path in Python?
The correct operator to extend a pathlib object is / from pathlib import Path Desktop = Path(‘Desktop’) # print(Desktop) WindowsPath(‘Desktop’) # extend the path to include subdir SubDeskTop = Desktop / “subdir” # print(SubDeskTop) WindowsPath(‘Desktop/subdir’) # passing an absolute path has different behavior SubDeskTop = Path(‘Desktop’) / ‘/subdir’ # print(SubDeskTop) WindowsPath(‘/subdir’) When several absolute paths … Read more