Python3 File isatty() Method
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
-
None
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