描述
方法symlink()創建符號鏈接dst指向src。
用法
以下是語法symlink()方法 -
os.symlink(src, dst)
參數
src- 這是來源。
dest- 這是以前不存在的目的地。
返回值
此方法不返回任何值。
示例
下麵的例子展示了 symlink() 方法的用法。
#!/usr/bin/python3
import os
src = '/usr/bin/python3'
dst = '/tmp/python'
# This creates a symbolic link on python in tmp directory
os.symlink(src, dst)
print ("symlink created")
結果
讓我們編譯並運行上麵的程序,這將在 /tmp 目錄中創建一個符號鏈接,如下所示 -
lrwxrwxrwx. 1 root root 15 Apr 30 03:00 python -> /usr/bin/python3
相關用法
- Python 3 os.statvfs()用法及代碼示例
- Python 3 os.stat()用法及代碼示例
- Python 3 os.stat_float_times()用法及代碼示例
- Python 3 os.fstatvfs()用法及代碼示例
- Python 3 os.minor()用法及代碼示例
- Python 3 os.close()用法及代碼示例
- Python 3 os.unlink()用法及代碼示例
- Python 3 os.major()用法及代碼示例
- Python 3 os.rmdir()用法及代碼示例
- Python 3 os.fdopen()用法及代碼示例
- Python 3 os.fdatasync()用法及代碼示例
- Python 3 os.isatty()用法及代碼示例
- Python 3 os.rename()用法及代碼示例
- Python 3 os.walk()用法及代碼示例
- Python 3 os.renames()用法及代碼示例
- Python 3 os.makedirs()用法及代碼示例
- Python 3 os.utime()用法及代碼示例
- Python 3 os.tcgetpgrp()用法及代碼示例
- Python 3 os.lchown()用法及代碼示例
- Python 3 os.mknod()用法及代碼示例
注:本文由純淨天空篩選整理自 Python 3 - os.symlink() Method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。