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://www.codercto.com/courses/l/10.html

查看所有标签

Hacking Growth

Hacking Growth

Sean Ellis、Morgan Brown / Crown Business / 2017-4-25 / USD 29.00

The definitive playbook by the pioneers of Growth Hacking, one of the hottest business methodologies in Silicon Valley and beyond. It seems hard to believe today, but there was a time when Airbnb w......一起来看看 《Hacking Growth》 这本书的介绍吧!

JSON 在线解析
JSON 在线解析

在线 JSON 格式化工具

URL 编码/解码
URL 编码/解码

URL 编码/解码

XML 在线格式化
XML 在线格式化

在线 XML 格式化压缩工具