Python3 File isatty() 方法
Python 3 教程
· 2019-02-06 22:42:52
概述
isatty() 方法检测文件是否连接到一个终端设备,如果是返回 True,否则返回 False。
语法
isatty() 方法语法如下:
fileObject.isatty();
参数
无
返回值
如果连接到一个终端设备返回 True,否则返回 False。
实例
以下实例演示了 isatty() 方法的使用:
#!/usr/bin/python3
# 打开文件
fo = open("codercto.txt", "wb")
print ("文件名为: ", fo.name)
ret = fo.isatty()
print ("返回值 : ", ret)
# 关闭文件
fo.close()
以上实例输出结果为:
文件名为: codercto.txt 返回值 : False
点击查看所有 Python 3 教程 文章: https://codercto.com/courses/l/10.html
Markdown 在线编辑器
Markdown 在线编辑器
正则表达式在线测试
正则表达式在线测试