Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Python3 File isatty() Method

Python3 File isatty() Method

Python3 File Methods Python3 File methods


Overview

isatty() The method checks whether the file is connected to a terminal device, returning True if so and False otherwise.

Syntax

The isatty() method syntax is as follows:


fileObject.isatty(); 

Parameters

Return Value

Returns True if connected to a terminal device, otherwise False.

Example

The following example shows how to use the isatty() method:


#!/usr/bin/python3

# Open file
fo = open("runoob.txt", "wb")
print ("文件名为: ", fo.name)

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

# Close file
fo.close()

The output of the above example is:


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

Python3 File Methods Python3 File methods