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

查看所有标签

Squid: The Definitive Guide

Squid: The Definitive Guide

Duane Wessels / O'Reilly Media / 2004 / $44.95 US, $65.95 CA, £31.95 UK

Squid is the most popular Web caching software in use today, and it works on a variety of platforms including Linux, FreeBSD, and Windows. Squid improves network performance by reducing the amount of......一起来看看 《Squid: The Definitive Guide》 这本书的介绍吧!

随机密码生成器
随机密码生成器

多种字符组合密码

html转js在线工具
html转js在线工具

html转js在线工具

正则表达式在线测试
正则表达式在线测试

正则表达式在线测试