chown()方法更改路徑的所有者和組id為數字uid和gid。 如要退出時 ID 不變,需要將其設置為-1。要設置所有權,需要超級用戶許可權..
	
語法
		以下是 chown() 方法的語法:
	
os.chown(path, uid, gid)
參數
- 
			
path -- 這是它的所有者ID和組ID,需要被設置的路徑。
 - 
			
uid -- 這是要設置的檔所有者ID。
 - 
			
gid -- 這是要設置的檔組ID。
 
返回值
		此方法不返回任何值。
	
	示例
		下麵的示例顯示 chown() 方法的使用。
	
#!/usr/bin/python3
import os, sys
# Assuming /tmp/foo.txt exists.
# To set owner ID 100 following has to be done.
os.chown("/tmp/foo.txt", 100, -1)
print ("Changed ownership successfully!!")
	
		當我們運行上面的程式,它會產生以下結果:
	
Changed ownership successfully!!
						上一篇:
								Python3檔方法
												下一篇:
								Python3 os檔目錄的方法
					
					