例如:
判断文件是否已连接到终端设备:
f = open("demofile.txt", "r")print(f.isatty())
1、定义和用法
如果文件流是交互式的,则isatty()
方法返回True
,例如:连接到终端设备。
2、调用语法
file.isatty()
3、参数说明
没有参数
4、使用示例
#!/usr/bin/python# -*- coding: UTF-8 -*-# 打开文件fo = open("demofile.txt", "wb")print "文件名为: ", fo.nameret = fo.isatty()print "返回值 : ", ret# 关闭文件fo.close()