Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> Python

วิธีสร้างไฟล์ Duplicate จากไฟล์ที่มีอยู่ใน Python

เหมือนบทความก่อนหน้า ใช้ shutil.copy() สร้างไฟล์ duplicate

ตัวอย่าง

>>> import shutil
>>> shutil.copy('original.txt', 'duplicate.txt')
'/home/username/duplicate.txt'
>>> shutil.copy('original.txt', 'my_folder/duplicate.txt')
'/home/username/my_folder/duplicate.txt'