“Salinan shutil” Kode Jawaban

Instal Shutil

pip install pytest-shutil
Talhah Patelia

Salinan shutil

# Python program to explain shutil.copy() method
   
# importing shutil module
import shutil
 
# Source path
source = "/home/User/Documents/file.txt"
 
# Destination path
destination = "/home/User/Documents/file.txt"
 
# Copy the content of
# source to destination
 
try:
    shutil.copy(source, destination)
    print("File copied successfully.")
 
# If source and destination are same
except shutil.SameFileError:
    print("Source and destination represents the same file.")
 
# If there is any permission issue
except PermissionError:
    print("Permission denied.")
 
# For other errors
except:
    print("Error occurred while copying file.")
MVP

Jawaban yang mirip dengan “Salinan shutil”

Pertanyaan yang mirip dengan “Salinan shutil”

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya