To delete a file or folder in Python, you can use the os module and call the os.remove() function to delete a file, or the shutil.rmtree() function to delete a folder and all its contents.