file.isatty()
描述 (Description)
如果文件连接(与终端设备关联)到tty(类似)设备,则方法isatty()返回True,否则返回False。
语法 (Syntax)
以下是isatty()方法的语法 -
fileObject.isatty();
参数 (Parameters)
NA
返回值 (Return Value)
如果文件连接(与终端设备关联)到tty(类似)设备,则此方法返回true,否则返回false。
例子 (Example)
以下示例显示了isatty()方法的用法。
#!/usr/bin/python
# Open a file
fo = open("foo.txt", "wb")
print "Name of the file: ", fo.name
ret = fo.isatty()
print "Return value : ", ret
# Close opend file
fo.close()
当我们运行上面的程序时,它产生以下结果 -
Name of the file: foo.txt
Return value : False