Python file methodisatty()如果文件连接(与终端设备关联)到tty(-like)设备,则返回True,否则返回False。
fileObject.isatty();
如果文件连接(与终端设备相关联)到tty(类似)设备,则此方法返回true,否则返回false。
以下示例显示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()
当无涯教程运行上面的程序时,它产生以下输出-
链接:https://www.learnfk.comhttps://www.learnfk.com/python/file-isatty.html
来源:LearnFk无涯教程网
Name of the file: foo.txt Return value : False
祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)