#Python3 os.isatty() 方法
#用于判断如果文件描述符fd是打开的,同时与tty(-like)设备相连,则返回true, 否则False。
====================
#!/usr/bin/python3
import os, sys
# 打开文件
fd = os.open( "foo.txt", os.O_RDWR|os.O_CREAT )
# 写入字符串
str = "This is runoob.com site"
os.write(fd,bytes(str, 'UTF-8'))
# 使用 isatty() 查看文件
ret = os.isatty(fd)
print ("返回值: ", ret)
# 关闭文件
os.close( fd )
|