copendir() 函數在 Linux 中用于復制一個目錄及其內容
如果你想在復制目錄時保留符號鏈接,可以使用 shutil.copytree() 函數。這個函數在 Python 的 shutil 模塊中,它可以將整個目錄及其內容復制到目標位置,并保留符號鏈接。以下是一個示例:
import shutil
src_dir = '/path/to/source/directory'
dst_dir = '/path/to/destination/directory'
shutil.copytree(src_dir, dst_dir, symlinks=True)
在這個示例中,symlinks=True 參數表示在復制過程中保留符號鏈接。