file.isatty()

本页内容
上一节: Python3_file_fileno 下一节: Python3_file_next

Python3 File isatty() 方法

Python3 File(文件) 方法

概述

isatty() 方法检测文件是否连接到一个终端设备,如果是返回 True,否则返回 False。

语法

isatty() 方法语法如下:


示例

fileObject.isatty();

参数

返回值

如果连接到一个终端设备返回 True,否则返回 False。

==

以下实例演示了 isatty() 方法的使用:


示例

#!/usr/bin/python3

# 打开文件
fo = open("xiaobai.txt", "wb")
print ("文件名为: ", fo.name)

ret = fo.isatty()
print ("返回值 : ", ret)

# 关闭文件
fo.close()

以上实例输出结果为:


示例

文件名为:  xiaobai.txt
返回值 :  False

Python3 File(文件) 方法

上一节: Python3_file_fileno 下一节: Python3_file_next
此页面最后编辑于2022年8月17日 (星期三) 21:08。