Open this example in the interactive library
Source code
from pathlib import PurePosixPath
print(PurePosixPath('report.csv').with_suffix('.json'))Sample output
report.json

Change a file extension. A self-contained example using the Python standard library.
Open this example in the interactive library
from pathlib import PurePosixPath
print(PurePosixPath('report.csv').with_suffix('.json'))report.json