Python os.tcsetpgrp() 方法
python os.tcsetpgrp() 方法
os.tcsetpgrp() 方法用于設(shè)置與終端fd(一個(gè)由os.open()返回的打開的文件描述符)關(guān)聯(lián)的進(jìn)程組為pg。
語(yǔ)法
tcsetpgrp()方法語(yǔ)法格式如下:
os.tcsetpgrp(fd, pg)
參數(shù)
- fd -- 文件描述符。
- pg -- 關(guān)聯(lián)的進(jìn)程組。
返回值
該方法沒有返回值。
實(shí)例
以下實(shí)例演示了 tcsetpgrp() 方法的使用:
#!/usr/bin/python
# -*- coding: utf-8 -*-
import os, sys
# 顯示當(dāng)前目錄
print "當(dāng)前目錄 :%s" %os.getcwd()
# 修改目錄到 /dev/tty
fd = os.open("/dev/tty",os.o_rdonly)
f = os.tcgetpgrp(fd)
# 顯示進(jìn)程組
print "關(guān)聯(lián)進(jìn)程組: "
print f
# 設(shè)置進(jìn)程組
os.tcsetpgrp(fd,2672)
print "done"
os.close(fd)
print "關(guān)閉文件成功!!"
執(zhí)行以上程序輸出結(jié)果為:
當(dāng)前目錄 :/tmp 關(guān)聯(lián)進(jìn)程組: 2672 done 關(guān)閉文件成功!!
相關(guān)文章
- Python 條件語(yǔ)句
- Python break 語(yǔ)句
- Python 字典 Dictionary
- Python File 方法
- Python 面向?qū)ο?/a>
- Python2 與 Python3?? 版本區(qū)別
- Python 詞典
- Python 集合
- Python 搜索樹
- Python 圖形
- Python 算法分析
- Python 遞歸
- Python 回溯
- Python 攤銷分析
- Python3 注釋
- Python3 字符串(String)
- Python3 if else 語(yǔ)句
- Python3 面向?qū)ο?/a>
- Python3 日期和時(shí)間
- Python MongoDB 數(shù)據(jù)庫(kù)連接 - PyMongo 驅(qū)動(dòng)

python os 文件/目錄方法
